Fix pylint errors in common/modules

This commit is contained in:
Philipp Hörist 2018-09-11 22:25:55 +02:00 committed by Philipp Hörist
parent 7c523f4b79
commit 58ad5cd4d5
36 changed files with 287 additions and 249 deletions

View File

@ -76,7 +76,7 @@ class Annotations:
iq = nbxmpp.Iq(typ='set') iq = nbxmpp.Iq(typ='set')
iq2 = iq.addChild(name='query', namespace=nbxmpp.NS_PRIVATE) iq2 = iq.addChild(name='query', namespace=nbxmpp.NS_PRIVATE)
iq3 = iq2.addChild(name='storage', namespace='storage:rosternotes') iq3 = iq2.addChild(name='storage', namespace='storage:rosternotes')
for jid in self.annotations.keys(): for jid in self.annotations:
if self.annotations[jid]: if self.annotations[jid]:
iq4 = iq3.addChild(name='note') iq4 = iq3.addChild(name='note')
iq4.setAttr('jid', jid) iq4.setAttr('jid', jid)
@ -85,7 +85,8 @@ class Annotations:
self._con.connection.SendAndCallForResponse( self._con.connection.SendAndCallForResponse(
iq, self._store_result_received) iq, self._store_result_received)
def _store_result_received(self, stanza): @staticmethod
def _store_result_received(stanza):
if not nbxmpp.isResultNode(stanza): if not nbxmpp.isResultNode(stanza):
log.warning('Storing rosternotes failed: %s', stanza.getError()) log.warning('Storing rosternotes failed: %s', stanza.getError())
return return

View File

@ -28,9 +28,10 @@ Implement more features if you need
# register the module in connection.py with register_module() to activate again # register the module in connection.py with register_module() to activate again
import logging import logging
import nbxmpp
import time import time
import nbxmpp
from gajim.common.const import PEPEventType from gajim.common.const import PEPEventType
from gajim.common.exceptions import StanzaMalformed from gajim.common.exceptions import StanzaMalformed
from gajim.common.modules.pep import AbstractPEPModule, AbstractPEPData from gajim.common.modules.pep import AbstractPEPModule, AbstractPEPData
@ -69,8 +70,11 @@ class Atom(AbstractPEPModule):
return OldEntry(node=entry) or None return OldEntry(node=entry) or None
def _build_node(self, data):
raise NotImplementedError
class PersonConstruct(nbxmpp.Node, object):
class PersonConstruct(nbxmpp.Node):
""" """
Not used for now, as we don't need authors/contributors Not used for now, as we don't need authors/contributors
in pubsub.com feeds. They rarely exist there in pubsub.com feeds. They rarely exist there
@ -87,7 +91,8 @@ class PersonConstruct(nbxmpp.Node, object):
get_name, None, None, get_name, None, None,
'''Conveys a human-readable name for the person. Should not be None, '''Conveys a human-readable name for the person. Should not be None,
although some badly generated atom feeds don't put anything here although some badly generated atom feeds don't put anything here
(this is non-standard behavior, still pubsub.com sometimes does that.)''') (this is non-standard behavior, still pubsub.com sometimes
does that.)''')
def get_uri(self): def get_uri(self):
return self.getTagData('uri') return self.getTagData('uri')
@ -102,11 +107,11 @@ class PersonConstruct(nbxmpp.Node, object):
email = property( email = property(
get_email, None, None, get_email, None, None,
'''Conveys an e-mail address associated with the person. Might be None when '''Conveys an e-mail address associated with the person.
not set.''') Might be None when not set.''')
class Entry(nbxmpp.Node, object): class Entry(nbxmpp.Node):
def __init__(self, node=None): def __init__(self, node=None):
nbxmpp.Node.__init__(self, 'entry', node=node) nbxmpp.Node.__init__(self, 'entry', node=node)
@ -114,7 +119,7 @@ class Entry(nbxmpp.Node, object):
return '<Atom:Entry object of id="%r">' % self.getAttr('id') return '<Atom:Entry object of id="%r">' % self.getAttr('id')
class OldEntry(nbxmpp.Node, object): class OldEntry(nbxmpp.Node):
""" """
Parser for feeds from pubsub.com. They use old Atom 0.3 format with their Parser for feeds from pubsub.com. They use old Atom 0.3 format with their
extensions extensions
@ -144,12 +149,11 @@ class OldEntry(nbxmpp.Node, object):
if main_feed is not None and source_feed is not None: if main_feed is not None and source_feed is not None:
return '%s: %s' % (main_feed, source_feed) return '%s: %s' % (main_feed, source_feed)
elif main_feed is not None: if main_feed is not None:
return main_feed return main_feed
elif source_feed is not None: if source_feed is not None:
return source_feed return source_feed
else: return ''
return ''
feed_title = property( feed_title = property(
get_feed_title, None, None, get_feed_title, None, None,
@ -161,7 +165,8 @@ class OldEntry(nbxmpp.Node, object):
Get source link Get source link
""" """
try: try:
return self.getTag('feed').getTags('link', {'rel': 'alternate'})[1].getData() link = self.getTag('feed').getTags('link', {'rel': 'alternate'})
return link[1].getData()
except Exception: except Exception:
return None return None

View File

@ -37,7 +37,7 @@ class Blocking:
self.supported = False self.supported = False
def pass_disco(self, from_, identities, features, data, node): def pass_disco(self, from_, _identities, features, _data, _node):
if nbxmpp.NS_BLOCKING not in features: if nbxmpp.NS_BLOCKING not in features:
return return
@ -71,7 +71,7 @@ class Blocking:
app.nec.push_incoming_event( app.nec.push_incoming_event(
BlockingEvent(None, conn=self._con, changed=self.blocked)) BlockingEvent(None, conn=self._con, changed=self.blocked))
def _blocking_push_received(self, conn, stanza): def _blocking_push_received(self, _con, stanza):
reply = stanza.buildReply('result') reply = stanza.buildReply('result')
childs = reply.getChildren() childs = reply.getChildren()
for child in childs: for child in childs:
@ -153,7 +153,8 @@ class Blocking:
self._con.connection.SendAndCallForResponse( self._con.connection.SendAndCallForResponse(
iq, self._default_result_handler, {}) iq, self._default_result_handler, {})
def _default_result_handler(self, conn, stanza): @staticmethod
def _default_result_handler(_con, stanza):
if not nbxmpp.isResultNode(stanza): if not nbxmpp.isResultNode(stanza):
log.warning('Operation failed: %s', stanza.getError()) log.warning('Operation failed: %s', stanza.getError())

View File

@ -29,6 +29,8 @@ from gajim.common.modules.util import to_xs_boolean
log = logging.getLogger('gajim.c.m.bookmarks') log = logging.getLogger('gajim.c.m.bookmarks')
NS_GAJIM_BM = 'xmpp:gajim.org/bookmarks'
class Bookmarks: class Bookmarks:
def __init__(self, con): def __init__(self, con):
@ -84,7 +86,7 @@ class Bookmarks:
'', 'storage:bookmarks', '', 'storage:bookmarks',
cb=self._pubsub_bookmarks_received) cb=self._pubsub_bookmarks_received)
def _pubsub_bookmarks_received(self, conn, stanza): def _pubsub_bookmarks_received(self, _con, stanza):
if not nbxmpp.isResultNode(stanza): if not nbxmpp.isResultNode(stanza):
log.info('No pubsub bookmarks: %s', stanza.getError()) log.info('No pubsub bookmarks: %s', stanza.getError())
# Fallback, request private storage # Fallback, request private storage
@ -158,7 +160,6 @@ class Bookmarks:
if storage is None: if storage is None:
return return
NS_GAJIM_BM = 'xmpp:gajim.org/bookmarks'
confs = storage.getTags('conference') confs = storage.getTags('conference')
for conf in confs: for conf in confs:
autojoin_val = conf.getAttr('autojoin') autojoin_val = conf.getAttr('autojoin')
@ -183,8 +184,8 @@ class Bookmarks:
try: try:
jid = helpers.parse_jid(conf.getAttr('jid')) jid = helpers.parse_jid(conf.getAttr('jid'))
except helpers.InvalidFormat: except helpers.InvalidFormat:
log.warning('Invalid JID: %s, ignoring it' log.warning('Invalid JID: %s, ignoring it',
% conf.getAttr('jid')) conf.getAttr('jid'))
continue continue
if check_merge: if check_merge:
@ -204,7 +205,6 @@ class Bookmarks:
return merged return merged
def _build_storage_node(self): def _build_storage_node(self):
NS_GAJIM_BM = 'xmpp:gajim.org/bookmarks'
storage_node = nbxmpp.Node( storage_node = nbxmpp.Node(
tag='storage', attrs={'xmlns': 'storage:bookmarks'}) tag='storage', attrs={'xmlns': 'storage:bookmarks'})
for jid, bm in self.bookmarks.items(): for jid, bm in self.bookmarks.items():
@ -231,11 +231,11 @@ class Bookmarks:
def get_bookmark_publish_options(): def get_bookmark_publish_options():
options = nbxmpp.Node(nbxmpp.NS_DATA + ' x', options = nbxmpp.Node(nbxmpp.NS_DATA + ' x',
attrs={'type': 'submit'}) attrs={'type': 'submit'})
f = options.addChild('field', field = options.addChild('field',
attrs={'var': 'FORM_TYPE', 'type': 'hidden'}) attrs={'var': 'FORM_TYPE', 'type': 'hidden'})
f.setTagData('value', nbxmpp.NS_PUBSUB_PUBLISH_OPTIONS) field.setTagData('value', nbxmpp.NS_PUBSUB_PUBLISH_OPTIONS)
f = options.addChild('field', attrs={'var': 'pubsub#access_model'}) field = options.addChild('field', attrs={'var': 'pubsub#access_model'})
f.setTagData('value', 'whitelist') field.setTagData('value', 'whitelist')
return options return options
def store_bookmarks(self, storage_type=None): def store_bookmarks(self, storage_type=None):
@ -267,12 +267,14 @@ class Bookmarks:
self._con.connection.SendAndCallForResponse( self._con.connection.SendAndCallForResponse(
iq, self._private_store_result) iq, self._private_store_result)
def _pubsub_store_result(self, conn, stanza): @staticmethod
def _pubsub_store_result(_con, stanza):
if not nbxmpp.isResultNode(stanza): if not nbxmpp.isResultNode(stanza):
log.error('Error: %s', stanza.getError()) log.error('Error: %s', stanza.getError())
return return
def _private_store_result(self, stanza): @staticmethod
def _private_store_result(stanza):
if not nbxmpp.isResultNode(stanza): if not nbxmpp.isResultNode(stanza):
log.error('Error: %s', stanza.getError()) log.error('Error: %s', stanza.getError())
return return

View File

@ -41,7 +41,7 @@ class Caps:
self._capscache = caps_cache.capscache self._capscache = caps_cache.capscache
self._create_suitable_client_caps = caps_cache.create_suitable_client_caps self._create_suitable_client_caps = caps_cache.create_suitable_client_caps
def _presence_received(self, con, stanza): def _presence_received(self, _con, stanza):
hash_method = node = caps_hash = None hash_method = node = caps_hash = None
caps = stanza.getTag('c', namespace=nbxmpp.NS_CAPS) caps = stanza.getTag('c', namespace=nbxmpp.NS_CAPS)
@ -73,19 +73,19 @@ class Caps:
self._update_client_caps_of_contact(from_, client_caps) self._update_client_caps_of_contact(from_, client_caps)
# Event is only used by ClientIcons Plugin # Event is only used by ClientIcons Plugin
app.nec.push_incoming_event(NetworkEvent( app.nec.push_incoming_event(
'caps-presence-received', NetworkEvent('caps-presence-received',
conn=self._con, conn=self._con,
fjid=full_jid, fjid=full_jid,
jid=from_.getStripped(), jid=from_.getStripped(),
resource=from_.getResource(), resource=from_.getResource(),
hash_method=hash_method, hash_method=hash_method,
node=node, node=node,
caps_hash=caps_hash, caps_hash=caps_hash,
client_caps=client_caps, client_caps=client_caps,
show=show, show=show,
ptype=type_, ptype=type_,
stanza=stanza)) stanza=stanza))
app.nec.push_incoming_event(NetworkEvent('caps-update', app.nec.push_incoming_event(NetworkEvent('caps-update',
conn=self._con, conn=self._con,
@ -97,7 +97,7 @@ class Caps:
if contact is not None: if contact is not None:
contact.client_caps = client_caps contact.client_caps = client_caps
else: else:
log.info('Received Caps from unknown contact %s' % from_) log.info('Received Caps from unknown contact %s', from_)
def _get_contact_or_gc_contact_for_jid(self, from_): def _get_contact_or_gc_contact_for_jid(self, from_):
contact = app.contacts.get_contact_from_full_jid(self._account, contact = app.contacts.get_contact_from_full_jid(self._account,
@ -118,7 +118,7 @@ class Caps:
contact = self._get_contact_or_gc_contact_for_jid(from_) contact = self._get_contact_or_gc_contact_for_jid(from_)
if not contact: if not contact:
log.info('Received Disco from unknown contact %s' % from_) log.info('Received Disco from unknown contact %s', from_)
return return
lookup = contact.client_caps.get_cache_lookup_strategy() lookup = contact.client_caps.get_cache_lookup_strategy()
@ -128,25 +128,25 @@ class Caps:
# we already know that the hash is fine and have already cached # we already know that the hash is fine and have already cached
# the identities and features # the identities and features
return return
validate = contact.client_caps.get_hash_validation_strategy()
hash_is_valid = validate(identities, features, data)
if hash_is_valid:
cache_item.set_and_store(identities, features)
else: else:
validate = contact.client_caps.get_hash_validation_strategy() node = caps_hash = hash_method = None
hash_is_valid = validate(identities, features, data) contact.client_caps = self._create_suitable_client_caps(
node, caps_hash, hash_method)
log.warning(
'Computed and retrieved caps hash differ. Ignoring '
'caps of contact %s', contact.get_full_jid())
if hash_is_valid: app.nec.push_incoming_event(
cache_item.set_and_store(identities, features) NetworkEvent('caps-update',
else: conn=self._con,
node = caps_hash = hash_method = None fjid=str(from_),
contact.client_caps = self._create_suitable_client_caps( jid=bare_jid))
node, caps_hash, hash_method)
log.warning(
'Computed and retrieved caps hash differ. Ignoring '
'caps of contact %s' % contact.get_full_jid())
app.nec.push_incoming_event(
NetworkEvent('caps-update',
conn=self._con,
fjid=str(from_),
jid=bare_jid))
def get_instance(*args, **kwargs): def get_instance(*args, **kwargs):

View File

@ -32,7 +32,7 @@ class Carbons:
self.supported = False self.supported = False
def pass_disco(self, from_, identities, features, data, node): def pass_disco(self, from_, _identities, features, _data, _node):
if nbxmpp.NS_CARBONS not in features: if nbxmpp.NS_CARBONS not in features:
return return

View File

@ -71,19 +71,18 @@ class LocalTimezone(tzinfo):
def utcoffset(self, dt): def utcoffset(self, dt):
if self._isdst(dt): if self._isdst(dt):
return DSTOFFSET return DSTOFFSET
else: return STDOFFSET
return STDOFFSET
def dst(self, dt): def dst(self, dt):
if self._isdst(dt): if self._isdst(dt):
return DSTDIFF return DSTDIFF
else: return ZERO
return ZERO
def tzname(self, dt): def tzname(self, dt):
return 'local' return 'local'
def _isdst(self, dt): @staticmethod
def _isdst(dt):
tt = (dt.year, dt.month, dt.day, tt = (dt.year, dt.month, dt.day,
dt.hour, dt.minute, dt.second, dt.hour, dt.minute, dt.second,
dt.weekday(), 0, 0) dt.weekday(), 0, 0)

View File

@ -62,7 +62,8 @@ class Delimiter:
self._con.connection.SendAndCallForResponse( self._con.connection.SendAndCallForResponse(
iq, self._set_delimiter_response) iq, self._set_delimiter_response)
def _set_delimiter_response(self, stanza): @staticmethod
def _set_delimiter_response(stanza):
if not nbxmpp.isResultNode(stanza): if not nbxmpp.isResultNode(stanza):
log.info('Store error: %s', stanza.getError()) log.info('Store error: %s', stanza.getError())

View File

@ -72,7 +72,7 @@ class Discovery:
iq, self._disco_response, {'success_cb': weak_success_cb, iq, self._disco_response, {'success_cb': weak_success_cb,
'error_cb': weak_error_cb}) 'error_cb': weak_error_cb})
def _disco_response(self, conn, stanza, success_cb, error_cb): def _disco_response(self, _con, stanza, success_cb, error_cb):
if not nbxmpp.isResultNode(stanza): if not nbxmpp.isResultNode(stanza):
if error_cb is not None: if error_cb is not None:
error_cb()(stanza.getFrom(), stanza.getError()) error_cb()(stanza.getFrom(), stanza.getError())
@ -115,16 +115,16 @@ class Discovery:
@classmethod @classmethod
def parse_info_response(cls, stanza): def parse_info_response(cls, stanza):
identities, features, data, node = [], [], [], None identities, features, data, node = [], [], [], None
q = stanza.getTag('query') query = stanza.getTag('query')
node = q.getAttr('node') node = query.getAttr('node')
if not node: if not node:
node = '' node = ''
qc = stanza.getQueryChildren() childs = stanza.getQueryChildren()
if not qc: if not childs:
qc = [] childs = []
for i in qc: for i in childs:
if i.getName() == 'identity': if i.getName() == 'identity':
attr = {} attr = {}
for key in i.getAttrs().keys(): for key in i.getAttrs().keys():
@ -143,7 +143,7 @@ class Discovery:
server = self._con.get_own_jid().getDomain() server = self._con.get_own_jid().getDomain()
self.disco_items(server, success_cb=self._server_items_received) self.disco_items(server, success_cb=self._server_items_received)
def _server_items_received(self, from_, node, items): def _server_items_received(self, _from, _node, items):
log.info('Server items received') log.info('Server items received')
for item in items: for item in items:
if 'node' in item: if 'node' in item:
@ -178,7 +178,7 @@ class Discovery:
self._con.get_module('PEP').pass_disco(from_, *args) self._con.get_module('PEP').pass_disco(from_, *args)
self._con.get_module('PubSub').pass_disco(from_, *args) self._con.get_module('PubSub').pass_disco(from_, *args)
identities, features, data, node = args features = args[1]
if 'urn:xmpp:pep-vcard-conversion:0' in features: if 'urn:xmpp:pep-vcard-conversion:0' in features:
self._con.avatar_conversion = True self._con.avatar_conversion = True
@ -197,7 +197,7 @@ class Discovery:
self._con.get_module('PrivacyLists').pass_disco(from_, *args) self._con.get_module('PrivacyLists').pass_disco(from_, *args)
self._con.get_module('HTTPUpload').pass_disco(from_, *args) self._con.get_module('HTTPUpload').pass_disco(from_, *args)
identities, features, data, node = args features = args[1]
if nbxmpp.NS_REGISTER in features: if nbxmpp.NS_REGISTER in features:
self._con.register_supported = True self._con.register_supported = True
@ -206,7 +206,7 @@ class Discovery:
self._con.connect_machine(restart=True) self._con.connect_machine(restart=True)
def _parse_transports(self, from_, identities, features, data, node): def _parse_transports(self, from_, identities, _features, _data, _node):
for identity in identities: for identity in identities:
category = identity.get('category') category = identity.get('category')
if category not in ('gateway', 'headline'): if category not in ('gateway', 'headline'):
@ -224,7 +224,7 @@ class Discovery:
else: else:
self._con.available_transports[transport_type] = [jid] self._con.available_transports[transport_type] = [jid]
def _answer_disco_items(self, con, stanza): def _answer_disco_items(self, _con, stanza):
from_ = stanza.getFrom() from_ = stanza.getFrom()
log.info('Answer disco items to %s', from_) log.info('Answer disco items to %s', from_)
@ -241,7 +241,7 @@ class Discovery:
self._con.get_module('AdHocCommands').command_list_query(stanza) self._con.get_module('AdHocCommands').command_list_query(stanza)
raise nbxmpp.NodeProcessed raise nbxmpp.NodeProcessed
def _answer_disco_info(self, con, stanza): def _answer_disco_info(self, _con, stanza):
from_ = stanza.getFrom() from_ = stanza.getFrom()
log.info('Answer disco info %s', from_) log.info('Answer disco info %s', from_)
if str(from_).startswith('echo.'): if str(from_).startswith('echo.'):
@ -260,10 +260,10 @@ class Discovery:
client_version = 'http://gajim.org#' + app.caps_hash[self._account] client_version = 'http://gajim.org#' + app.caps_hash[self._account]
if node in (None, client_version): if node in (None, client_version):
for f in app.gajim_common_features: for feature in app.gajim_common_features:
query.addChild('feature', attrs={'var': f}) query.addChild('feature', attrs={'var': feature})
for f in app.gajim_optional_features[self._account]: for feature in app.gajim_optional_features[self._account]:
query.addChild('feature', attrs={'var': f}) query.addChild('feature', attrs={'var': feature})
self._con.connection.send(iq) self._con.connection.send(iq)
raise nbxmpp.NodeProcessed raise nbxmpp.NodeProcessed
@ -281,7 +281,8 @@ class Discovery:
self._con.connection.SendAndCallForResponse( self._con.connection.SendAndCallForResponse(
iq, self._muc_info_response, {'callback': callback}) iq, self._muc_info_response, {'callback': callback})
def _muc_info_response(self, conn, stanza, callback): @staticmethod
def _muc_info_response(_con, stanza, callback):
if not nbxmpp.isResultNode(stanza): if not nbxmpp.isResultNode(stanza):
error = stanza.getError() error = stanza.getError()
if error == 'item-not-found': if error == 'item-not-found':

View File

@ -66,7 +66,8 @@ class EntityTime:
jid=stanza.getFrom(), jid=stanza.getFrom(),
time_info=time_info)) time_info=time_info))
def _extract_info(self, stanza): @staticmethod
def _extract_info(stanza):
time_ = stanza.getTag('time') time_ = stanza.getTag('time')
if not time_: if not time_:
log.warning('No time node: %s', stanza) log.warning('No time node: %s', stanza)
@ -94,23 +95,23 @@ class EntityTime:
return return
try: try:
t = datetime.datetime.strptime(utc_time, '%Y-%m-%dT%H:%M:%S') dtime = datetime.datetime.strptime(utc_time, '%Y-%m-%dT%H:%M:%S')
except ValueError: except ValueError:
try: try:
t = datetime.datetime.strptime(utc_time, dtime = datetime.datetime.strptime(utc_time,
'%Y-%m-%dT%H:%M:%S.%f') '%Y-%m-%dT%H:%M:%S.%f')
except ValueError as e: except ValueError as error:
log.warning('Wrong time format: %s %s', log.warning('Wrong time format: %s %s',
e, stanza.getFrom()) error, stanza.getFrom())
return return
utc = datetime.timezone(datetime.timedelta(0)) utc = datetime.timezone(datetime.timedelta(0))
t = t.replace(tzinfo=utc) dtime = dtime.replace(tzinfo=utc)
utc_offset = datetime.timedelta(hours=int(tzoh), minutes=int(tzom)) utc_offset = datetime.timedelta(hours=int(tzoh), minutes=int(tzom))
contact_tz = datetime.timezone(utc_offset, "remote timezone") contact_tz = datetime.timezone(utc_offset, "remote timezone")
return t.astimezone(contact_tz).strftime('%c') return dtime.astimezone(contact_tz).strftime('%c')
def _answer_request(self, con, stanza): def _answer_request(self, _con, stanza):
log.info('%s asked for the time', stanza.getFrom()) log.info('%s asked for the time', stanza.getFrom())
if app.config.get_per('accounts', self._account, 'send_time_info'): if app.config.get_per('accounts', self._account, 'send_time_info'):
iq = stanza.buildReply('result') iq = stanza.buildReply('result')

View File

@ -34,7 +34,7 @@ class HTTPAuth:
('message', self.answer_request, '', nbxmpp.NS_HTTP_AUTH) ('message', self.answer_request, '', nbxmpp.NS_HTTP_AUTH)
] ]
def answer_request(self, con, stanza): def answer_request(self, _con, stanza):
log.info('Auth request received') log.info('Auth request received')
auto_answer = app.config.get_per( auto_answer = app.config.get_per(
'accounts', self._account, 'http_auth') 'accounts', self._account, 'http_auth')

View File

@ -76,7 +76,7 @@ class HTTPUpload:
ged.OUT_PREGUI, ged.OUT_PREGUI,
self.handle_outgoing_stanza) self.handle_outgoing_stanza)
def pass_disco(self, from_, identities, features, data, node): def pass_disco(self, from_, _identities, features, data, _node):
if NS_HTTPUPLOAD_0 in features: if NS_HTTPUPLOAD_0 in features:
self.httpupload_namespace = NS_HTTPUPLOAD_0 self.httpupload_namespace = NS_HTTPUPLOAD_0
elif NS_HTTPUPLOAD in features: elif NS_HTTPUPLOAD in features:
@ -219,7 +219,7 @@ class HTTPUpload:
return stanza.getErrorMsg() return stanza.getErrorMsg()
def _received_slot(self, conn, stanza, file): def _received_slot(self, _con, stanza, file):
log.info("Received slot") log.info("Received slot")
if stanza.getType() == 'error': if stanza.getType() == 'error':
self.raise_progress_event('close', file) self.raise_progress_event('close', file)
@ -283,7 +283,8 @@ class HTTPUpload:
file.put, data=file.stream, headers=file.headers, method='PUT') file.put, data=file.stream, headers=file.headers, method='PUT')
log.info("Opening Urllib upload request...") log.info("Opening Urllib upload request...")
if not app.config.get_per('accounts', self._account, 'httpupload_verify'): if not app.config.get_per(
'accounts', self._account, 'httpupload_verify'):
context = ssl.create_default_context() context = ssl.create_default_context()
context.check_hostname = False context.check_hostname = False
context.verify_mode = ssl.CERT_NONE context.verify_mode = ssl.CERT_NONE
@ -336,7 +337,7 @@ class HTTPUpload:
else: else:
app.nec.push_outgoing_event(MessageOutgoingEvent( app.nec.push_outgoing_event(MessageOutgoingEvent(
None, account=self._account, jid=file.contact.jid, None, account=self._account, jid=file.contact.jid,
message=message, keyID=file.keyID, type_='chat', message=message, keyID=file.key_id, type_='chat',
automatic_message=False, session=file.session)) automatic_message=False, session=file.session))
else: else:
@ -356,13 +357,13 @@ class HTTPUpload:
class File: class File:
def __init__(self, path, contact, **kwargs): def __init__(self, path, contact, **kwargs):
for k, v in kwargs.items(): for key, val in kwargs.items():
setattr(self, k, v) setattr(self, key, val)
self.encrypted = False self.encrypted = False
self.contact = contact self.contact = contact
self.keyID = None self.key_id = None
if hasattr(contact, 'keyID'): if hasattr(contact, 'keyID'):
self.keyID = contact.keyID self.key_id = contact.keyID
self.stream = None self.stream = None
self.path = path self.path = path
self.put = None self.put = None

View File

@ -31,7 +31,7 @@ class LastActivity:
self.handlers = [('iq', self._answer_request, 'get', nbxmpp.NS_LAST)] self.handlers = [('iq', self._answer_request, 'get', nbxmpp.NS_LAST)]
def _answer_request(self, con, stanza): def _answer_request(self, _con, stanza):
log.info('Request from %s', stanza.getFrom()) log.info('Request from %s', stanza.getFrom())
if not app.account_is_connected(self._account): if not app.account_is_connected(self._account):
return return

View File

@ -50,7 +50,7 @@ class MAM:
# Holds archive jids where catch up was successful # Holds archive jids where catch up was successful
self._catch_up_finished = [] self._catch_up_finished = []
def pass_disco(self, from_, identities, features, data, node): def pass_disco(self, from_, _identities, features, _data, _node):
if nbxmpp.NS_MAM_2 in features: if nbxmpp.NS_MAM_2 in features:
self.archiving_namespace = nbxmpp.NS_MAM_2 self.archiving_namespace = nbxmpp.NS_MAM_2
elif nbxmpp.NS_MAM_1 in features: elif nbxmpp.NS_MAM_1 in features:
@ -76,9 +76,9 @@ class MAM:
return return
# Message from our own archive # Message from our own archive
return self._con.get_own_jid() return self._con.get_own_jid()
else:
if archive_jid.bareMatch(expected_archive): if archive_jid.bareMatch(expected_archive):
return archive_jid return archive_jid
def _get_unique_id(self, result, message, groupchat, self_message, muc_pm): def _get_unique_id(self, result, message, groupchat, self_message, muc_pm):
stanza_id = result.getAttr('id') stanza_id = result.getAttr('id')
@ -99,7 +99,7 @@ class MAM:
# A message we received # A message we received
return stanza_id, None return stanza_id, None
def _mam_message_received(self, conn, stanza): def _mam_message_received(self, _con, stanza):
app.nec.push_incoming_event( app.nec.push_incoming_event(
NetworkIncomingEvent('raw-mam-message-received', NetworkIncomingEvent('raw-mam-message-received',
conn=self._con, conn=self._con,
@ -207,7 +207,8 @@ class MAM:
raise nbxmpp.NodeProcessed raise nbxmpp.NodeProcessed
def _parse_gc_attrs(self, message): @staticmethod
def _parse_gc_attrs(message):
with_ = message.getFrom() with_ = message.getFrom()
nick = message.getFrom().getResource() nick = message.getFrom().getResource()
@ -330,7 +331,7 @@ class MAM:
query, self._received_count, {'query_id': query_id}) query, self._received_count, {'query_id': query_id})
return query_id return query_id
def _received_count(self, conn, stanza, query_id): def _received_count(self, _con, stanza, query_id):
try: try:
_, set_ = self._parse_iq(stanza) _, set_ = self._parse_iq(stanza)
except InvalidMamIQ: except InvalidMamIQ:
@ -393,7 +394,8 @@ class MAM:
# of Messages even in just one day. # of Messages even in just one day.
start_date = datetime.utcnow() - timedelta(days=1) start_date = datetime.utcnow() - timedelta(days=1)
log.info('First join: query archive %s from: %s', jid, start_date) log.info('First join: query archive %s from: %s', jid, start_date)
query = self._get_archive_query(query_id, jid=jid, start=start_date) query = self._get_archive_query(
query_id, jid=jid, start=start_date)
if jid in self._catch_up_finished: if jid in self._catch_up_finished:
self._catch_up_finished.remove(jid) self._catch_up_finished.remove(jid)
@ -406,7 +408,7 @@ class MAM:
'start_date': start_date, 'start_date': start_date,
'groupchat': groupchat}) 'groupchat': groupchat})
def _result_finished(self, conn, stanza, query_id, start_date, groupchat): def _result_finished(self, _con, stanza, query_id, start_date, groupchat):
try: try:
fin, set_ = self._parse_iq(stanza) fin, set_ = self._parse_iq(stanza)
except InvalidMamIQ: except InvalidMamIQ:
@ -461,7 +463,7 @@ class MAM:
'end_date': end_date}) 'end_date': end_date})
return query_id return query_id
def _intervall_result(self, conn, stanza, query_id, def _intervall_result(self, _con, stanza, query_id,
start_date, end_date): start_date, end_date):
try: try:
fin, set_ = self._parse_iq(stanza) fin, set_ = self._parse_iq(stanza)
@ -510,9 +512,10 @@ class MAM:
value=namespace) value=namespace)
form.addChild(node=field) form.addChild(node=field)
if start: if start:
field = nbxmpp.DataField(typ='text-single', field = nbxmpp.DataField(
name='start', typ='text-single',
value=start.strftime('%Y-%m-%dT%H:%M:%SZ')) name='start',
value=start.strftime('%Y-%m-%dT%H:%M:%SZ'))
form.addChild(node=field) form.addChild(node=field)
if end: if end:
field = nbxmpp.DataField(typ='text-single', field = nbxmpp.DataField(typ='text-single',
@ -520,7 +523,9 @@ class MAM:
value=end.strftime('%Y-%m-%dT%H:%M:%SZ')) value=end.strftime('%Y-%m-%dT%H:%M:%SZ'))
form.addChild(node=field) form.addChild(node=field)
if with_: if with_:
field = nbxmpp.DataField(typ='jid-single', name='with', value=with_) field = nbxmpp.DataField(typ='jid-single',
name='with',
value=with_)
form.addChild(node=field) form.addChild(node=field)
set_ = query.setTag('set', namespace=nbxmpp.NS_RSM) set_ = query.setTag('set', namespace=nbxmpp.NS_RSM)

View File

@ -57,7 +57,7 @@ class Message:
nbxmpp.NS_CONFERENCE, nbxmpp.NS_CONFERENCE,
nbxmpp.NS_IBB]) nbxmpp.NS_IBB])
def _message_received(self, con, stanza): def _message_received(self, _con, stanza):
# https://tools.ietf.org/html/rfc6120#section-8.1.1.1 # https://tools.ietf.org/html/rfc6120#section-8.1.1.1
# If the stanza does not include a 'to' address then the client MUST # If the stanza does not include a 'to' address then the client MUST
# treat it as if the 'to' address were included with a value of the # treat it as if the 'to' address were included with a value of the
@ -262,7 +262,7 @@ class Message:
DecryptedMessageReceivedEvent( DecryptedMessageReceivedEvent(
None, **vars(event))) None, **vars(event)))
def _get_unique_id(self, stanza, forwarded, sent, self_message, muc_pm): def _get_unique_id(self, stanza, _forwarded, _sent, self_message, _muc_pm):
if stanza.getType() == 'groupchat': if stanza.getType() == 'groupchat':
# TODO: Disco the MUC check if 'urn:xmpp:mam:2' is announced # TODO: Disco the MUC check if 'urn:xmpp:mam:2' is announced
return self._get_stanza_id(stanza), None return self._get_stanza_id(stanza), None

View File

@ -98,7 +98,8 @@ class MetaContacts:
self._con.connection.SendAndCallForResponse( self._con.connection.SendAndCallForResponse(
iq, self._store_response_received) iq, self._store_response_received)
def _store_response_received(self, stanza): @staticmethod
def _store_response_received(stanza):
if not nbxmpp.isResultNode(stanza): if not nbxmpp.isResultNode(stanza):
log.info('Store error: %s', stanza.getError()) log.info('Store error: %s', stanza.getError())

View File

@ -112,7 +112,7 @@ def parse_correction(stanza):
id_ = replace.getAttr('id') id_ = replace.getAttr('id')
if id_ is not None: if id_ is not None:
return id_ return id_
log.warning('No id attr found: %s' % stanza) log.warning('No id attr found: %s', stanza)
# XEP-0224: Attention # XEP-0224: Attention

View File

@ -40,7 +40,7 @@ class MUC:
('message', self._direct_invite, '', nbxmpp.NS_CONFERENCE), ('message', self._direct_invite, '', nbxmpp.NS_CONFERENCE),
] ]
def pass_disco(self, from_, identities, features, data, node): def pass_disco(self, from_, identities, features, _data, _node):
for identity in identities: for identity in identities:
if identity.get('category') != 'conference': if identity.get('category') != 'conference':
continue continue
@ -248,7 +248,7 @@ class MUC:
self._con.connection.SendAndCallForResponse( self._con.connection.SendAndCallForResponse(
iq, self._default_response, {}) iq, self._default_response, {})
def _mediated_invite(self, con, stanza): def _mediated_invite(self, _con, stanza):
muc_user = stanza.getTag('x', namespace=nbxmpp.NS_MUC_USER) muc_user = stanza.getTag('x', namespace=nbxmpp.NS_MUC_USER)
if muc_user is None: if muc_user is None:
return return
@ -313,7 +313,7 @@ class MUC:
return from_ return from_
def _direct_invite(self, con, stanza): def _direct_invite(self, _con, stanza):
direct = stanza.getTag('x', namespace=nbxmpp.NS_CONFERENCE) direct = stanza.getTag('x', namespace=nbxmpp.NS_CONFERENCE)
if direct is None: if direct is None:
return return
@ -354,7 +354,8 @@ class MUC:
invite = self._build_mediated_invite(room, to, reason, continue_) invite = self._build_mediated_invite(room, to, reason, continue_)
self._con.connection.send(invite) self._con.connection.send(invite)
def _build_direct_invite(self, room, to, reason, continue_): @staticmethod
def _build_direct_invite(room, to, reason, continue_):
message = nbxmpp.Message(to=to) message = nbxmpp.Message(to=to)
attrs = {'jid': room} attrs = {'jid': room}
if reason: if reason:
@ -368,7 +369,8 @@ class MUC:
namespace=nbxmpp.NS_CONFERENCE) namespace=nbxmpp.NS_CONFERENCE)
return message return message
def _build_mediated_invite(self, room, to, reason, continue_): @staticmethod
def _build_mediated_invite(room, to, reason, continue_):
message = nbxmpp.Message(to=room) message = nbxmpp.Message(to=room)
muc_user = message.addChild('x', namespace=nbxmpp.NS_MUC_USER) muc_user = message.addChild('x', namespace=nbxmpp.NS_MUC_USER)
invite = muc_user.addChild('invite', attrs={'to': to}) invite = muc_user.addChild('invite', attrs={'to': to})
@ -395,16 +397,17 @@ class MUC:
if not app.account_is_connected(self._account): if not app.account_is_connected(self._account):
return return
message = nbxmpp.Message(to=room) message = nbxmpp.Message(to=room)
x = nbxmpp.DataForm(typ='submit') xdata = nbxmpp.DataForm(typ='submit')
x.addChild(node=nbxmpp.DataField(name='FORM_TYPE', xdata.addChild(node=nbxmpp.DataField(name='FORM_TYPE',
value=nbxmpp.NS_MUC + '#request')) value=nbxmpp.NS_MUC + '#request'))
x.addChild(node=nbxmpp.DataField(name='muc#role', xdata.addChild(node=nbxmpp.DataField(name='muc#role',
value='participant', value='participant',
typ='text-single')) typ='text-single'))
message.addChild(node=x) message.addChild(node=xdata)
self._con.connection.send(message) self._con.connection.send(message)
def _default_response(self, conn, stanza, **kwargs): @staticmethod
def _default_response(_con, stanza, **kwargs):
if not nbxmpp.isResultNode(stanza): if not nbxmpp.isResultNode(stanza):
log.info('Error: %s', stanza.getError()) log.info('Error: %s', stanza.getError())

View File

@ -40,7 +40,7 @@ class PEP:
self._pep_handlers = {} self._pep_handlers = {}
self._store_publish_modules = [] self._store_publish_modules = []
def pass_disco(self, from_, identities, features, data, node): def pass_disco(self, from_, identities, _features, _data, _node):
for identity in identities: for identity in identities:
if identity['category'] == 'pubsub': if identity['category'] == 'pubsub':
if identity.get('type') == 'pep': if identity.get('type') == 'pep':
@ -59,7 +59,7 @@ class PEP:
if module_instance not in self._store_publish_modules: if module_instance not in self._store_publish_modules:
self._store_publish_modules.append(module_instance) self._store_publish_modules.append(module_instance)
def _pep_event_received(self, conn, stanza): def _pep_event_received(self, _con, stanza):
jid = stanza.getFrom() jid = stanza.getFrom()
event = stanza.getTag('event', namespace=nbxmpp.NS_PUBSUB_EVENT) event = stanza.getTag('event', namespace=nbxmpp.NS_PUBSUB_EVENT)
items = event.getTag('items') items = event.getTag('items')

View File

@ -35,7 +35,8 @@ class Ping:
('iq', self._answer_request, 'get', nbxmpp.NS_PING), ('iq', self._answer_request, 'get', nbxmpp.NS_PING),
] ]
def _get_ping_iq(self, to): @staticmethod
def _get_ping_iq(to):
iq = nbxmpp.Iq('get', to=to) iq = nbxmpp.Iq('get', to=to)
iq.addChild(name='ping', namespace=nbxmpp.NS_PING) iq.addChild(name='ping', namespace=nbxmpp.NS_PING)
return iq return iq
@ -54,7 +55,7 @@ class Ping:
'time_for_ping_alive_answer') 'time_for_ping_alive_answer')
self._alarm_time = app.idlequeue.set_alarm(self._reconnect, seconds) self._alarm_time = app.idlequeue.set_alarm(self._reconnect, seconds)
def _keepalive_received(self, stanza): def _keepalive_received(self, _stanza):
log.info('Received keepalive') log.info('Received keepalive')
app.idlequeue.remove_alarm(self._reconnect, self._alarm_time) app.idlequeue.remove_alarm(self._reconnect, self._alarm_time)
@ -83,7 +84,7 @@ class Ping:
app.nec.push_incoming_event( app.nec.push_incoming_event(
PingSentEvent(None, conn=self._con, contact=contact)) PingSentEvent(None, conn=self._con, contact=contact))
def _pong_received(self, con, stanza, ping_time, contact): def _pong_received(self, _con, stanza, ping_time, contact):
if not nbxmpp.isResultNode(stanza): if not nbxmpp.isResultNode(stanza):
log.info('Error: %s', stanza.getError()) log.info('Error: %s', stanza.getError())
app.nec.push_incoming_event( app.nec.push_incoming_event(
@ -97,11 +98,11 @@ class Ping:
contact=contact, contact=contact,
seconds=diff)) seconds=diff))
def _answer_request(self, con, stanza): def _answer_request(self, _con, stanza):
iq = stanza.buildReply('result') iq = stanza.buildReply('result')
q = iq.getTag('ping') ping = iq.getTag('ping')
if q is not None: if ping is not None:
iq.delChild(q) iq.delChild(ping)
self._con.connection.send(iq) self._con.connection.send(iq)
log.info('Send pong to %s', stanza.getFrom()) log.info('Send pong to %s', stanza.getFrom())
raise nbxmpp.NodeProcessed raise nbxmpp.NodeProcessed

View File

@ -45,7 +45,7 @@ class Presence:
# list of jid to auto-authorize # list of jid to auto-authorize
self.jids_for_auto_auth = [] self.jids_for_auto_auth = []
def _presence_received(self, con, stanza): def _presence_received(self, _con, stanza):
if stanza.getType() in ('subscribe', 'subscribed', if stanza.getType() in ('subscribe', 'subscribed',
'unsubscribe', 'unsubscribed'): 'unsubscribe', 'unsubscribed'):
# Dont handle that here # Dont handle that here
@ -60,7 +60,7 @@ class Presence:
conn=self._con, conn=self._con,
stanza=stanza)) stanza=stanza))
def _subscribe_received(self, con, stanza): def _subscribe_received(self, _con, stanza):
from_ = stanza.getFrom() from_ = stanza.getFrom()
jid = from_.getStripped() jid = from_.getStripped()
fjid = str(from_) fjid = str(from_)
@ -73,7 +73,7 @@ class Presence:
'user_nick: %s', from_, is_transport, auto_auth, user_nick) 'user_nick: %s', from_, is_transport, auto_auth, user_nick)
if is_transport and fjid in self._con.agent_registrations: if is_transport and fjid in self._con.agent_registrations:
self._con.agent_registrations[fjid]['sub_received'] = True self._con.agent_registrations[fjid]['sub_received'] = True
if not self.agent_registrations[fjid]['roster_push']: if not self._con.agent_registrations[fjid]['roster_push']:
# We'll reply after roster push result # We'll reply after roster push result
raise nbxmpp.NodeProcessed raise nbxmpp.NodeProcessed
@ -94,7 +94,7 @@ class Presence:
raise nbxmpp.NodeProcessed raise nbxmpp.NodeProcessed
def _subscribed_received(self, con, stanza): def _subscribed_received(self, _con, stanza):
from_ = stanza.getFrom() from_ = stanza.getFrom()
jid = from_.getStripped() jid = from_.getStripped()
resource = from_.getResource() resource = from_.getResource()
@ -108,11 +108,12 @@ class Presence:
conn=self._con, jid=jid, resource=resource)) conn=self._con, jid=jid, resource=resource))
raise nbxmpp.NodeProcessed raise nbxmpp.NodeProcessed
def _unsubscribe_received(self, con, stanza): @staticmethod
def _unsubscribe_received(_con, stanza):
log.info('Received Unsubscribe: %s', stanza.getFrom()) log.info('Received Unsubscribe: %s', stanza.getFrom())
raise nbxmpp.NodeProcessed raise nbxmpp.NodeProcessed
def _unsubscribed_received(self, con, stanza): def _unsubscribed_received(self, _con, stanza):
from_ = stanza.getFrom() from_ = stanza.getFrom()
jid = from_.getStripped() jid = from_.getStripped()
log.info('Received Unsubscribed: %s', from_) log.info('Received Unsubscribed: %s', from_)
@ -147,8 +148,7 @@ class Presence:
self._con.getRoster().Unsubscribe(jid) self._con.getRoster().Unsubscribe(jid)
self._con.getRoster().setItem(jid) self._con.getRoster().setItem(jid)
def subscribe(self, jid, msg=None, name='', groups=None, def subscribe(self, jid, msg=None, name='', groups=None, auto_auth=False):
auto_auth=False, user_nick=''):
if not app.account_is_connected(self._account): if not app.account_is_connected(self._account):
return return
if groups is None: if groups is None:

View File

@ -45,7 +45,7 @@ class PrivacyLists:
self.supported = False self.supported = False
def pass_disco(self, from_, identities, features, data, node): def pass_disco(self, from_, _identities, features, _data, _node):
if nbxmpp.NS_PRIVACY not in features: if nbxmpp.NS_PRIVACY not in features:
return return
@ -55,7 +55,7 @@ class PrivacyLists:
action = app.app.lookup_action('%s-privacylists' % self._account) action = app.app.lookup_action('%s-privacylists' % self._account)
action.set_enabled(True) action.set_enabled(True)
def _list_push_received(self, con, stanza): def _list_push_received(self, _con, stanza):
result = stanza.buildReply('result') result = stanza.buildReply('result')
result.delChild(result.getTag('query')) result.delChild(result.getTag('query'))
self._con.connection.send(result) self._con.connection.send(result)
@ -74,7 +74,7 @@ class PrivacyLists:
self._con.connection.SendAndCallForResponse( self._con.connection.SendAndCallForResponse(
iq, self._privacy_lists_received, {'callback': callback}) iq, self._privacy_lists_received, {'callback': callback})
def _privacy_lists_received(self, conn, stanza, callback): def _privacy_lists_received(self, _con, stanza, callback):
lists = [] lists = []
new_default = None new_default = None
result = nbxmpp.isResultNode(stanza) result = nbxmpp.isResultNode(stanza)
@ -233,15 +233,16 @@ class PrivacyLists:
self._con.connection.SendAndCallForResponse( self._con.connection.SendAndCallForResponse(
iq, self._default_result_handler, {}) iq, self._default_result_handler, {})
def _default_result_handler(self, conn, stanza): @staticmethod
def _default_result_handler(_con, stanza):
if not nbxmpp.isResultNode(stanza): if not nbxmpp.isResultNode(stanza):
log.warning('Operation failed: %s', stanza.getError()) log.warning('Operation failed: %s', stanza.getError())
def _build_invisible_rule(self): def _build_invisible_rule(self):
node = nbxmpp.Node('list', {'name': 'invisible'}) node = nbxmpp.Node('list', {'name': 'invisible'})
iq = nbxmpp.Iq('set', nbxmpp.NS_PRIVACY, payload=[node]) iq = nbxmpp.Iq('set', nbxmpp.NS_PRIVACY, payload=[node])
if self._account in app.interface.status_sent_to_groups and \ if (self._account in app.interface.status_sent_to_groups and
len(app.interface.status_sent_to_groups[self._account]) > 0: app.interface.status_sent_to_groups[self._account]):
for group in app.interface.status_sent_to_groups[self._account]: for group in app.interface.status_sent_to_groups[self._account]:
item = node.setTag('item', {'type': 'group', item = node.setTag('item', {'type': 'group',
'value': group, 'value': group,
@ -249,8 +250,8 @@ class PrivacyLists:
'order': '1'}) 'order': '1'})
item.setTag('presence-out') item.setTag('presence-out')
if self._account in app.interface.status_sent_to_users and \ if (self._account in app.interface.status_sent_to_users and
len(app.interface.status_sent_to_users[self._account]) > 0: app.interface.status_sent_to_users[self._account]):
for jid in app.interface.status_sent_to_users[self._account]: for jid in app.interface.status_sent_to_users[self._account]:
item = node.setTag('item', {'type': 'jid', item = node.setTag('item', {'type': 'jid',
'value': jid, 'value': jid,
@ -330,11 +331,12 @@ class PrivacyLists:
log.info('Unblock GC contact: %s', jid) log.info('Unblock GC contact: %s', jid)
for rule in self.blocked_list: for rule in self.blocked_list:
if rule['action'] != 'deny' or rule['type'] != 'jid' \ if (rule['action'] != 'deny' or
or rule['value'] != jid: rule['type'] != 'jid' or
rule['value'] != jid):
new_blocked_list.append(rule) new_blocked_list.append(rule)
if len(new_blocked_list) == 0: if not new_blocked_list:
self.blocked_list = [] self.blocked_list = []
self.blocked_contacts = [] self.blocked_contacts = []
self.blocked_groups = [] self.blocked_groups = []
@ -356,11 +358,12 @@ class PrivacyLists:
if contact.jid in self.blocked_contacts: if contact.jid in self.blocked_contacts:
self.blocked_contacts.remove(contact.jid) self.blocked_contacts.remove(contact.jid)
for rule in self.blocked_list: for rule in self.blocked_list:
if rule['action'] != 'deny' or rule['type'] != 'jid' \ if (rule['action'] != 'deny' or
or rule['value'] not in to_unblock: rule['type'] != 'jid' or
rule['value'] not in to_unblock):
new_blocked_list.append(rule) new_blocked_list.append(rule)
if len(new_blocked_list) == 0: if not new_blocked_list:
self.blocked_list = [] self.blocked_list = []
self.blocked_contacts = [] self.blocked_contacts = []
self.blocked_groups = [] self.blocked_groups = []
@ -415,11 +418,12 @@ class PrivacyLists:
log.info('Unblock group: %s', group) log.info('Unblock group: %s', group)
new_blocked_list = [] new_blocked_list = []
for rule in self.blocked_list: for rule in self.blocked_list:
if rule['action'] != 'deny' or rule['type'] != 'group' or \ if (rule['action'] != 'deny' or
rule['value'] != group: rule['type'] != 'group' or
rule['value'] != group):
new_blocked_list.append(rule) new_blocked_list.append(rule)
if len(new_blocked_list) == 0: if not new_blocked_list:
self.blocked_list = [] self.blocked_list = []
self.blocked_contacts = [] self.blocked_contacts = []
self.blocked_groups = [] self.blocked_groups = []

View File

@ -40,7 +40,7 @@ class PubSub:
self.publish_options = False self.publish_options = False
def pass_disco(self, from_, identities, features, data, node): def pass_disco(self, from_, _identities, features, _data, _node):
if nbxmpp.NS_PUBSUB_PUBLISH_OPTIONS not in features: if nbxmpp.NS_PUBSUB_PUBLISH_OPTIONS not in features:
# Remove stored bookmarks accessible to everyone. # Remove stored bookmarks accessible to everyone.
self._con.get_module('Bookmarks').purge_pubsub_bookmarks() self._con.get_module('Bookmarks').purge_pubsub_bookmarks()
@ -89,15 +89,15 @@ class PubSub:
cb = self._default_callback cb = self._default_callback
query = nbxmpp.Iq('set', to=jid) query = nbxmpp.Iq('set', to=jid)
e = query.addChild('pubsub', namespace=nbxmpp.NS_PUBSUB) pubsub = query.addChild('pubsub', namespace=nbxmpp.NS_PUBSUB)
p = e.addChild('publish', {'node': node}) publish = pubsub.addChild('publish', {'node': node})
attrs = {} attrs = {}
if id_: if id_:
attrs = {'id': id_} attrs = {'id': id_}
p.addChild('item', attrs, [item]) publish.addChild('item', attrs, [item])
if options: if options:
p = e.addChild('publish-options') publish = pubsub.addChild('publish-options')
p.addChild(node=options) publish.addChild(node=options)
self._con.connection.SendAndCallForResponse(query, cb, kwargs) self._con.connection.SendAndCallForResponse(query, cb, kwargs)
@ -107,10 +107,10 @@ class PubSub:
Get IQ to query items from a node Get IQ to query items from a node
""" """
query = nbxmpp.Iq('get', to=jid) query = nbxmpp.Iq('get', to=jid)
r = query.addChild('pubsub', namespace=nbxmpp.NS_PUBSUB) pubsub = query.addChild('pubsub', namespace=nbxmpp.NS_PUBSUB)
r = r.addChild('items', {'node': node}) items = pubsub.addChild('items', {'node': node})
if item_id is not None: if item_id is not None:
r.addChild('item', {'id': item_id}) items.addChild('item', {'id': item_id})
return query return query
def send_pb_retrieve(self, jid, node, item_id=None, cb=None, **kwargs): def send_pb_retrieve(self, jid, node, item_id=None, cb=None, **kwargs):
@ -138,9 +138,9 @@ class PubSub:
cb = self._default_callback cb = self._default_callback
query = nbxmpp.Iq('set', to=jid) query = nbxmpp.Iq('set', to=jid)
r = query.addChild('pubsub', namespace=nbxmpp.NS_PUBSUB) pubsub = query.addChild('pubsub', namespace=nbxmpp.NS_PUBSUB)
r = r.addChild('retract', {'node': node, 'notify': '1'}) retract = pubsub.addChild('retract', {'node': node, 'notify': '1'})
r = r.addChild('item', {'id': id_}) retract.addChild('item', {'id': id_})
self._con.connection.SendAndCallForResponse(query, cb, kwargs) self._con.connection.SendAndCallForResponse(query, cb, kwargs)
@ -155,8 +155,8 @@ class PubSub:
cb = self._default_callback cb = self._default_callback
query = nbxmpp.Iq('set', to=jid) query = nbxmpp.Iq('set', to=jid)
d = query.addChild('pubsub', namespace=nbxmpp.NS_PUBSUB_OWNER) pubsub = query.addChild('pubsub', namespace=nbxmpp.NS_PUBSUB_OWNER)
d = d.addChild('purge', {'node': node}) pubsub.addChild('purge', {'node': node})
self._con.connection.SendAndCallForResponse(query, cb, kwargs) self._con.connection.SendAndCallForResponse(query, cb, kwargs)
@ -167,10 +167,10 @@ class PubSub:
if not app.account_is_connected(self._account): if not app.account_is_connected(self._account):
return return
query = nbxmpp.Iq('set', to=jid) query = nbxmpp.Iq('set', to=jid)
d = query.addChild('pubsub', namespace=nbxmpp.NS_PUBSUB_OWNER) pubsub = query.addChild('pubsub', namespace=nbxmpp.NS_PUBSUB_OWNER)
d = d.addChild('delete', {'node': node}) pubsub.addChild('delete', {'node': node})
def response(con, resp, jid, node): def response(_con, resp, jid, node):
if resp.getType() == 'result' and on_ok: if resp.getType() == 'result' and on_ok:
on_ok(jid, node) on_ok(jid, node)
elif on_fail: elif on_fail:
@ -188,10 +188,10 @@ class PubSub:
if not app.account_is_connected(self._account): if not app.account_is_connected(self._account):
return return
query = nbxmpp.Iq('set', to=jid) query = nbxmpp.Iq('set', to=jid)
c = query.addChild('pubsub', namespace=nbxmpp.NS_PUBSUB) pubsub = query.addChild('pubsub', namespace=nbxmpp.NS_PUBSUB)
c = c.addChild('create', {'node': node}) create = pubsub.addChild('create', {'node': node})
if configure: if configure:
conf = c.addChild('configure') conf = create.addChild('configure')
if configure_form is not None: if configure_form is not None:
conf.addChild(node=configure_form) conf.addChild(node=configure_form)
@ -205,9 +205,9 @@ class PubSub:
cb = self._default_callback cb = self._default_callback
query = nbxmpp.Iq('set', to=jid) query = nbxmpp.Iq('set', to=jid)
c = query.addChild('pubsub', namespace=nbxmpp.NS_PUBSUB_OWNER) pubsub = query.addChild('pubsub', namespace=nbxmpp.NS_PUBSUB_OWNER)
c = c.addChild('configure', {'node': node}) configure = pubsub.addChild('configure', {'node': node})
c.addChild(node=form) configure.addChild(node=form)
log.info('Send node config for %s', node) log.info('Send node config for %s', node)
self._con.connection.SendAndCallForResponse(query, cb, kwargs) self._con.connection.SendAndCallForResponse(query, cb, kwargs)
@ -217,14 +217,14 @@ class PubSub:
return return
query = nbxmpp.Iq('get', to=jid) query = nbxmpp.Iq('get', to=jid)
e = query.addChild('pubsub', namespace=nbxmpp.NS_PUBSUB_OWNER) pubsub = query.addChild('pubsub', namespace=nbxmpp.NS_PUBSUB_OWNER)
e = e.addChild('configure', {'node': node}) pubsub.addChild('configure', {'node': node})
log.info('Request node config for %s', node) log.info('Request node config for %s', node)
self._con.connection.SendAndCallForResponse( self._con.connection.SendAndCallForResponse(
query, self._received_pb_configuration, {'node': node}) query, self._received_pb_configuration, {'node': node})
def _received_pb_configuration(self, conn, stanza, node): def _received_pb_configuration(self, _con, stanza, node):
if not nbxmpp.isResultNode(stanza): if not nbxmpp.isResultNode(stanza):
log.warning('Error: %s', stanza.getError()) log.warning('Error: %s', stanza.getError())
return return
@ -256,7 +256,8 @@ class PubSub:
None, conn=self._con, node=node, None, conn=self._con, node=node,
form=dataforms.ExtendForm(node=form))) form=dataforms.ExtendForm(node=form)))
def _default_callback(self, conn, stanza, *args, **kwargs): @staticmethod
def _default_callback(_con, stanza, *args, **kwargs):
if not nbxmpp.isResultNode(stanza): if not nbxmpp.isResultNode(stanza):
log.warning('Error: %s', stanza.getError()) log.warning('Error: %s', stanza.getError())

View File

@ -81,7 +81,8 @@ class Receipts:
event.jid, event.jid,
event.resource) event.resource)
def _build_answer_receipt(self, to, receipt_id): @staticmethod
def _build_answer_receipt(to, receipt_id):
receipt = nbxmpp.Message(to=to, typ='chat') receipt = nbxmpp.Message(to=to, typ='chat')
receipt.setTag('received', receipt.setTag('received',
namespace='urn:xmpp:receipts', namespace='urn:xmpp:receipts',

View File

@ -39,9 +39,9 @@ class Register:
hostname = app.config.get_per('accounts', self._account, 'hostname') hostname = app.config.get_per('accounts', self._account, 'hostname')
username = app.config.get_per('accounts', self._account, 'name') username = app.config.get_per('accounts', self._account, 'name')
iq = nbxmpp.Iq(typ='set', to=hostname) iq = nbxmpp.Iq(typ='set', to=hostname)
q = iq.setTag(nbxmpp.NS_REGISTER + ' query') query = iq.setTag(nbxmpp.NS_REGISTER + ' query')
q.setTagData('username', username) query.setTagData('username', username)
q.setTagData('password', password) query.setTagData('password', password)
weak_success_cb = weakref.WeakMethod(success_cb) weak_success_cb = weakref.WeakMethod(success_cb)
weak_error_cb = weakref.WeakMethod(error_cb) weak_error_cb = weakref.WeakMethod(error_cb)
@ -50,7 +50,8 @@ class Register:
iq, self._change_password_response, {'success_cb': weak_success_cb, iq, self._change_password_response, {'success_cb': weak_success_cb,
'error_cb': weak_error_cb}) 'error_cb': weak_error_cb})
def _change_password_response(self, con, stanza, success_cb, error_cb): @staticmethod
def _change_password_response(_con, stanza, success_cb, error_cb):
if not nbxmpp.isResultNode(stanza): if not nbxmpp.isResultNode(stanza):
error = stanza.getErrorMsg() error = stanza.getErrorMsg()
log.info('Error: %s', error) log.info('Error: %s', error)
@ -85,7 +86,7 @@ class Register:
self.agent_registrations[agent] = {'roster_push': False, self.agent_registrations[agent] = {'roster_push': False,
'sub_received': False} 'sub_received': False}
def _register_agent_response(self, con, stanza, agent, def _register_agent_response(self, _con, stanza, agent,
success_cb, error_cb): success_cb, error_cb):
if not nbxmpp.isResultNode(stanza): if not nbxmpp.isResultNode(stanza):
error = stanza.getErrorMsg() error = stanza.getErrorMsg()
@ -115,7 +116,8 @@ class Register:
iq, self._register_info_response, {'success_cb': weak_success_cb, iq, self._register_info_response, {'success_cb': weak_success_cb,
'error_cb': weak_error_cb}) 'error_cb': weak_error_cb})
def _register_info_response(self, con, stanza, success_cb, error_cb): @staticmethod
def _register_info_response(_con, stanza, success_cb, error_cb):
if not nbxmpp.isResultNode(stanza): if not nbxmpp.isResultNode(stanza):
error = stanza.getErrorMsg() error = stanza.getErrorMsg()
log.info('Error: %s', error) log.info('Error: %s', error)

View File

@ -106,7 +106,7 @@ class Roster:
self._con.connect_machine() self._con.connect_machine()
def _roster_push_received(self, con, stanza): def _roster_push_received(self, _con, stanza):
log.info('Push received') log.info('Push received')
sender = stanza.getFrom() sender = stanza.getFrom()
@ -197,13 +197,12 @@ class Roster:
attrs = self._get_item_attrs(item, update=False) attrs = self._get_item_attrs(item, update=False)
return RosterItem(jid, attrs) return RosterItem(jid, attrs)
if jid not in self._data:
self._data[jid] = self._get_item_attrs(item, update=False)
else: else:
if jid not in self._data: self._data[jid].update(self._get_item_attrs(item))
self._data[jid] = self._get_item_attrs(item, update=False)
else:
self._data[jid].update(self._get_item_attrs(item))
return RosterItem(jid, self._data[jid]) return RosterItem(jid, self._data[jid])
def _ack_roster_push(self, stanza): def _ack_roster_push(self, stanza):
iq = nbxmpp.Iq('result', iq = nbxmpp.Iq('result',
@ -212,7 +211,7 @@ class Roster:
attrs={'id': stanza.getID()}) attrs={'id': stanza.getID()})
self._con.connection.send(iq) self._con.connection.send(iq)
def _presence_received(self, con, pres): def _presence_received(self, _con, pres):
''' '''
Add contacts that request subscription to our internal Add contacts that request subscription to our internal
roster and also to the database. The contact is put into the roster and also to the database. The contact is put into the

View File

@ -35,7 +35,7 @@ class RosterItemExchange:
('message', self.received_item, '', nbxmpp.NS_ROSTERX) ('message', self.received_item, '', nbxmpp.NS_ROSTERX)
] ]
def received_item(self, con, stanza): def received_item(self, _con, stanza):
# stanza can be a message or a iq # stanza can be a message or a iq
log.info('Received roster items from %s', stanza.getFrom()) log.info('Received roster items from %s', stanza.getFrom())
@ -108,12 +108,12 @@ class RosterItemExchange:
body=msg) body=msg)
elif type_ == 'iq': elif type_ == 'iq':
stanza = nbxmpp.Iq(to=fjid, typ='set') stanza = nbxmpp.Iq(to=fjid, typ='set')
x = stanza.addChild(name='x', namespace=nbxmpp.NS_ROSTERX) xdata = stanza.addChild(name='x', namespace=nbxmpp.NS_ROSTERX)
for contact in contacts: for contact in contacts:
name = contact.get_shown_name() name = contact.get_shown_name()
x.addChild(name='item', attrs={'action': 'add', xdata.addChild(name='item', attrs={'action': 'add',
'jid': contact.jid, 'jid': contact.jid,
'name': name}) 'name': name})
log.info('Send contact: %s %s', contact.jid, name) log.info('Send contact: %s %s', contact.jid, name)
self._con.connection.send(stanza) self._con.connection.send(stanza)

View File

@ -91,10 +91,10 @@ class Search:
data = [] data = []
for item in tag.getTags('item'): for item in tag.getTags('item'):
# We also show attributes. jid is there # We also show attributes. jid is there
f = item.attrs field = item.attrs
for i in item.getPayload(): for i in item.getPayload():
f[i.getName()] = i.getData() field[i.getName()] = i.getData()
data.append(f) data.append(field)
else: else:
log.info('Error: %s', stanza.getError()) log.info('Error: %s', stanza.getError())

View File

@ -34,7 +34,7 @@ class SecLabels:
self._catalogs = {} self._catalogs = {}
self.supported = False self.supported = False
def pass_disco(self, from_, identities, features, data, node): def pass_disco(self, from_, _identities, features, _data, _node):
if nbxmpp.NS_SECLABEL not in features: if nbxmpp.NS_SECLABEL not in features:
return return

View File

@ -69,7 +69,8 @@ class SoftwareVersion:
client_info=client_info, client_info=client_info,
os_info=os_info)) os_info=os_info))
def _extract_info(self, stanza): @staticmethod
def _extract_info(stanza):
query = stanza.getTag('query') query = stanza.getTag('query')
name = query.getTag('name').getData() name = query.getTag('name').getData()
version = query.getTag('version').getData() version = query.getTag('version').getData()
@ -79,7 +80,7 @@ class SoftwareVersion:
os_info = os_info.getData() os_info = os_info.getData()
return client_info, os_info return client_info, os_info
def _answer_request(self, con, stanza): def _answer_request(self, _con, stanza):
log.info('%s asked for the software version', stanza.getFrom()) log.info('%s asked for the software version', stanza.getFrom())
if app.config.get_per('accounts', self._account, 'send_os_info'): if app.config.get_per('accounts', self._account, 'send_os_info'):
os_info = get_os_info() os_info = get_os_info()

View File

@ -92,7 +92,7 @@ class UserAvatar(AbstractPEPModule):
return jid, sha, data return jid, sha, data
def _avatar_received(self, conn, stanza): def _avatar_received(self, _con, stanza):
try: try:
jid, sha, data = self._validate_avatar_node(stanza) jid, sha, data = self._validate_avatar_node(stanza)
except (StanzaMalformed, binascii.Error) as error: except (StanzaMalformed, binascii.Error) as error:
@ -145,6 +145,9 @@ class UserAvatar(AbstractPEPModule):
return return
self.get_pubsub_avatar(jid, avatar['id']) self.get_pubsub_avatar(jid, avatar['id'])
def _build_node(self, data):
raise NotImplementedError
def send(self, data): def send(self, data):
# Not implemented yet # Not implemented yet
return return

View File

@ -41,11 +41,11 @@ class UserMoodData(AbstractPEPData):
markuptext += ' (%s)' % GLib.markup_escape_text(text) markuptext += ' (%s)' % GLib.markup_escape_text(text)
return markuptext return markuptext
def _translate_mood(self, mood): @staticmethod
def _translate_mood(mood):
if mood in MOODS: if mood in MOODS:
return MOODS[mood] return MOODS[mood]
else: return mood
return mood
class UserMood(AbstractPEPModule): class UserMood(AbstractPEPModule):

View File

@ -38,12 +38,12 @@ def is_muc_pm(message: nbxmpp.Node,
muc_user = message.getTag('x', namespace=nbxmpp.NS_MUC_USER) muc_user = message.getTag('x', namespace=nbxmpp.NS_MUC_USER)
if muc_user is not None: if muc_user is not None:
return muc_user.getChildren() == [] return muc_user.getChildren() == []
else:
# muc#user namespace was added in MUC 1.28 so we need a fallback # muc#user namespace was added in MUC 1.28 so we need a fallback
# Check if we know the jid # Check if we know the jid
if app.logger.jid_is_room_jid(jid.getStripped()): if app.logger.jid_is_room_jid(jid.getStripped()):
return True return True
return False return False
def from_xs_boolean(value: Union[str, bool]) -> bool: def from_xs_boolean(value: Union[str, bool]) -> bool:

View File

@ -50,7 +50,7 @@ class VCardAvatars:
log.info('Missing own avatar, reset sha') log.info('Missing own avatar, reset sha')
app.config.set_per('accounts', self._account, 'avatar_sha', '') app.config.set_per('accounts', self._account, 'avatar_sha', '')
def _presence_received(self, con, stanza): def _presence_received(self, _con, stanza):
update = stanza.getTag('x', namespace=nbxmpp.NS_VCARD_UPDATE) update = stanza.getTag('x', namespace=nbxmpp.NS_VCARD_UPDATE)
if update is None: if update is None:
return return

View File

@ -41,7 +41,7 @@ class VCardTemp:
self.room_jids = [] self.room_jids = []
self.supported = False self.supported = False
def pass_disco(self, from_, identities, features, data, node): def pass_disco(self, from_, _identities, features, _data, _node):
if nbxmpp.NS_VCARD not in features: if nbxmpp.NS_VCARD not in features:
return return
@ -51,22 +51,23 @@ class VCardTemp:
action = app.app.lookup_action('%s-profile' % self._account) action = app.app.lookup_action('%s-profile' % self._account)
action.set_enabled(True) action.set_enabled(True)
def _node_to_dict(self, node): @staticmethod
def _node_to_dict(node):
dict_ = {} dict_ = {}
for info in node.getChildren(): for info in node.getChildren():
name = info.getName() name = info.getName()
if name in ('ADR', 'TEL', 'EMAIL'): # we can have several if name in ('ADR', 'TEL', 'EMAIL'): # we can have several
dict_.setdefault(name, []) dict_.setdefault(name, [])
entry = {} entry = {}
for c in info.getChildren(): for child in info.getChildren():
entry[c.getName()] = c.getData() entry[child.getName()] = child.getData()
dict_[name].append(entry) dict_[name].append(entry)
elif info.getChildren() == []: elif info.getChildren() == []:
dict_[name] = info.getData() dict_[name] = info.getData()
else: else:
dict_[name] = {} dict_[name] = {}
for c in info.getChildren(): for child in info.getChildren():
dict_[name][c.getName()] = c.getData() dict_[name][child.getName()] = child.getData()
return dict_ return dict_
def request_vcard(self, callback=RequestAvatar.SELF, jid=None, def request_vcard(self, callback=RequestAvatar.SELF, jid=None,
@ -137,13 +138,14 @@ class VCardTemp:
self._con.connection.SendAndCallForResponse( self._con.connection.SendAndCallForResponse(
iq, self._upload_room_avatar_result) iq, self._upload_room_avatar_result)
def _upload_room_avatar_result(self, stanza): @staticmethod
def _upload_room_avatar_result(stanza):
if not nbxmpp.isResultNode(stanza): if not nbxmpp.isResultNode(stanza):
reason = stanza.getErrorMsg() or stanza.getError() reason = stanza.getErrorMsg() or stanza.getError()
app.nec.push_incoming_event(InformationEvent( app.nec.push_incoming_event(InformationEvent(
None, dialog_name='avatar-upload-error', args=reason)) None, dialog_name='avatar-upload-error', args=reason))
def _avatar_publish_result(self, con, stanza, sha): def _avatar_publish_result(self, _con, stanza, sha):
if stanza.getType() == 'result': if stanza.getType() == 'result':
current_sha = app.config.get_per( current_sha = app.config.get_per(
'accounts', self._account, 'avatar_sha') 'accounts', self._account, 'avatar_sha')
@ -166,7 +168,8 @@ class VCardTemp:
app.nec.push_incoming_event( app.nec.push_incoming_event(
VcardNotPublishedEvent(None, conn=self._con)) VcardNotPublishedEvent(None, conn=self._con))
def _get_vcard_photo(self, vcard, jid): @staticmethod
def _get_vcard_photo(vcard, jid):
try: try:
photo = vcard['PHOTO']['BINVAL'] photo = vcard['PHOTO']['BINVAL']
except (KeyError, AttributeError, TypeError): except (KeyError, AttributeError, TypeError):
@ -186,7 +189,7 @@ class VCardTemp:
return avatar_sha, photo_decoded return avatar_sha, photo_decoded
def _parse_vcard(self, con, stanza, callback, expected_sha): def _parse_vcard(self, _con, stanza, callback, expected_sha):
frm_jid = stanza.getFrom() frm_jid = stanza.getFrom()
room = False room = False
if frm_jid is None: if frm_jid is None:
@ -224,7 +227,7 @@ class VCardTemp:
callback(jid, resource, room, vcard, expected_sha) callback(jid, resource, room, vcard, expected_sha)
def _on_own_avatar_received(self, jid, resource, room, vcard, *args): def _on_own_avatar_received(self, jid, _resource, _room, vcard, *args):
avatar_sha, photo_decoded = self._get_vcard_photo(vcard, jid) avatar_sha, photo_decoded = self._get_vcard_photo(vcard, jid)
log.info('Received own vcard, avatar sha is: %s', avatar_sha) log.info('Received own vcard, avatar sha is: %s', avatar_sha)
@ -237,7 +240,8 @@ class VCardTemp:
log.info('No avatar found') log.info('No avatar found')
app.config.set_per('accounts', self._account, 'avatar_sha', '') app.config.set_per('accounts', self._account, 'avatar_sha', '')
app.contacts.set_avatar(self._account, jid, avatar_sha) app.contacts.set_avatar(self._account, jid, avatar_sha)
self._con.get_module('VCardAvatars').send_avatar_presence(force=True) self._con.get_module('VCardAvatars').send_avatar_presence(
force=True)
return return
# Avatar found in vcard # Avatar found in vcard
@ -250,11 +254,12 @@ class VCardTemp:
app.contacts.set_avatar(self._account, jid, avatar_sha) app.contacts.set_avatar(self._account, jid, avatar_sha)
app.config.set_per( app.config.set_per(
'accounts', self._account, 'avatar_sha', avatar_sha) 'accounts', self._account, 'avatar_sha', avatar_sha)
self._con.get_module('VCardAvatars').send_avatar_presence(force=True) self._con.get_module('VCardAvatars').send_avatar_presence(
force=True)
app.interface.update_avatar(self._account, jid) app.interface.update_avatar(self._account, jid)
def _on_room_avatar_received(self, jid, resource, room, vcard, def _on_room_avatar_received(self, jid, _resource, _room, vcard,
expected_sha): expected_sha):
avatar_sha, photo_decoded = self._get_vcard_photo(vcard, jid) avatar_sha, photo_decoded = self._get_vcard_photo(vcard, jid)
if expected_sha != avatar_sha: if expected_sha != avatar_sha:

View File

@ -2049,7 +2049,7 @@ class RosterWindow:
""" """
groups_list = groups or [] groups_list = groups or []
app.connections[account].get_module('Presence').subscribe( app.connections[account].get_module('Presence').subscribe(
jid, txt, nickname, groups_list, auto_auth, app.nicks[account]) jid, txt, nickname, groups_list, auto_auth)
contact = app.contacts.get_contact_with_highest_priority(account, jid) contact = app.contacts.get_contact_with_highest_priority(account, jid)
if not contact: if not contact:
keyID = '' keyID = ''