Commit 3370cc45 authored by Martin's avatar Martin

Imported upstream master from 2017-11-17

parent 7e9d331b
......@@ -277,13 +277,17 @@ class ConnectionVcard:
if self.get_own_jid().bareMatch(obj.jid):
app.log('avatar').info('Update (vCard): %s %s',
obj.jid, obj.avatar_sha)
obj.jid, obj.avatar_sha)
current_sha = app.config.get_per(
'accounts', self.name, 'avatar_sha')
if obj.avatar_sha != current_sha:
app.log('avatar').info(
'Request (vCard): %s', obj.jid)
self.request_vcard(self._on_own_avatar_received)
else:
app.log('avatar').info(
'Avatar already known (vCard): %s %s',
obj.jid, obj.avatar_sha)
return
if obj.avatar_sha == '':
......@@ -305,6 +309,10 @@ class ConnectionVcard:
app.log('avatar').info(
'Request (vCard): %s', obj.jid)
self.request_vcard(self._on_avatar_received, obj.jid)
else:
app.log('avatar').info(
'Avatar already known (vCard): %s %s',
obj.jid, obj.avatar_sha)
def _vcard_gc_presence_received(self, obj):
if obj.conn.name != self.name:
......@@ -348,6 +356,9 @@ class ConnectionVcard:
obj.nick, obj.avatar_sha)
gc_contact.avatar_sha = obj.avatar_sha
app.interface.update_avatar(contact=gc_contact)
else:
app.log('avatar').info(
'Avatar already known (vCard): %s', obj.nick)
def send_avatar_presence(self):
show = helpers.get_xmpp_show(app.SHOW_LIST[self.connected])
......@@ -2039,6 +2050,7 @@ ConnectionHandlersBase, ConnectionJingle, ConnectionIBBytestream):
p.setStatus(msg)
if signed:
p.setTag(nbxmpp.NS_SIGNED + ' x').setData(signed)
p = self.add_sha(p)
if self.connection:
self.connection.send(p)
......
......@@ -1354,6 +1354,10 @@ def update_optional_features(account = None):
app.gajim_optional_features[a].append(nbxmpp.NS_JINGLE_XTLS)
app.gajim_optional_features[a].append(nbxmpp.NS_JINGLE_BYTESTREAM)
app.gajim_optional_features[a].append(nbxmpp.NS_JINGLE_IBB)
# Give plugins the possibility to add their features
app.plugin_manager.extension_point('update_caps', a)
app.caps_hash[a] = caps_cache.compute_caps_hash([app.gajim_identity],
app.gajim_common_features + app.gajim_optional_features[a])
# re-send presence with new hash
......
......@@ -481,23 +481,36 @@ class AvatarNotificationPEP(AbstractPEP):
namespace = 'urn:xmpp:avatar:metadata'
def _extract_info(self, items):
avatar = None
self.avatar = None
for item in items.getTags('item'):
info = item.getTag('metadata').getTag('info')
self.avatar = info.getAttrs()
if info is not None:
self.avatar = info.getAttrs()
break
return (avatar, False)
return (None, False)
def _on_receive(self, jid, account):
sha = app.contacts.get_avatar_sha(account, jid)
app.log('avatar').info(
'Update (Pubsub): %s %s', jid, self.avatar['id'])
if sha == self.avatar['id']:
return
con = app.connections[account]
app.log('avatar').info('Request (Pubsub): %s', jid)
con.send_pb_retrieve(jid, 'urn:xmpp:avatar:data', self.avatar['id'])
if self.avatar is None:
# Remove avatar
app.log('avatar').debug('Remove (Pubsub): %s', jid)
app.contacts.set_avatar(account, jid, None)
own_jid = con.get_own_jid().getStripped()
app.logger.set_avatar_sha(own_jid, jid, None)
app.interface.update_avatar(account, jid)
else:
sha = app.contacts.get_avatar_sha(account, jid)
app.log('avatar').info(
'Update (Pubsub): %s %s', jid, self.avatar['id'])
if sha == self.avatar['id']:
app.log('avatar').info(
'Avatar already known (Pubsub): %s %s',
jid, self.avatar['id'])
return
app.log('avatar').info('Request (Pubsub): %s', jid)
con.send_pb_retrieve(jid, 'urn:xmpp:avatar:data',
self.avatar['id'])
SUPPORTED_PERSONAL_USER_EVENTS = [
......
......@@ -2562,10 +2562,6 @@ class Interface:
MessageWindowMgr.ONE_MSG_WINDOW_ALWAYS_WITH_ROSTER:
self.msg_win_mgr.create_window(None, None, None)
# Creating plugin manager
from gajim import plugins
app.plugin_manager = plugins.PluginManager()
self.roster._before_fill()
for account in app.connections:
app.connections[account].load_roster_from_db()
......@@ -2762,6 +2758,11 @@ class Interface:
app.gajim_optional_features[a] = []
app.caps_hash[a] = ''
# Creating plugin manager
from gajim import plugins
app.plugin_manager = plugins.PluginManager()
app.plugin_manager.init_plugins()
helpers.update_optional_features()
# prepopulate data which we are sure of; note: we do not log these info
for account in app.connections:
......
......@@ -110,7 +110,6 @@ class PluginManager(metaclass=Singleton):
for path in [app.PLUGINS_DIRS[1], app.PLUGINS_DIRS[0]]:
pc = PluginManager.scan_dir_for_plugins(path)
self.add_plugins(pc)
self._activate_all_plugins_from_global_config()
@log_calls('PluginManager')
def _plugin_has_entry_in_global_config(self, plugin):
......@@ -126,6 +125,10 @@ class PluginManager(metaclass=Singleton):
def _remove_plugin_entry_in_global_config(self, plugin):
app.config.del_per('plugins', plugin.short_name)
@log_calls('PluginManager')
def init_plugins(self):
self._activate_all_plugins_from_global_config()
@log_calls('PluginManager')
def add_plugin(self, plugin_class):
'''
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment