Philipp Hörist pushed to branch master at gajim / python-nbxmpp
Commits:
0264a744 by Philipp Hörist at 2017-07-25T02:25:24+02:00
Make better use of Protocol classes
Return always a xmpp aware Protocol instance on getTag().
Otherwise we would fall back to a xmpp unaware Node instance.
Return a Message instance in case the tag name is 'message'
- - - - -
0f51792d by Philipp Hörist at 2017-07-25T02:25:42+02:00
add getJid() attribute method
- - - - -
1 changed file:
- nbxmpp/protocol.py
Changes:
=====================================
nbxmpp/protocol.py
=====================================
--- a/nbxmpp/protocol.py
+++ b/nbxmpp/protocol.py
@@ -834,6 +834,15 @@ class Protocol(Node):
return self.timestamp
return time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime())
+ def getJid(self):
+ """
+ Return the value of the 'jid' attribute
+ """
+ attr = self.getAttr('jid')
+ if attr:
+ return JID(attr)
+ return attr
+
def getID(self):
"""
Return the value of the 'id' attribute
@@ -946,6 +955,16 @@ class Protocol(Node):
props.append(prop)
return props
+ def getTag(self, name, attrs=None, namespace=None):
+ """
+ Return at least a Protocol instance, so we dont fall back to simplexml level
+ """
+ tag = super().getTag(name, attrs, namespace)
+ if not tag:
+ return None
+
+ return Protocol(node=tag)
+
def __setitem__(self, item, val):
"""
Set the item 'item' to the value 'val'
@@ -1073,6 +1092,18 @@ class Message(Protocol):
attrs.append(child.getAttr('code'))
return attrs
+ def getTag(self, name, attrs=None, namespace=None):
+ """
+ Return Message instance, fallback to Protocol
+ """
+ tag = super().getTag(name, attrs, namespace)
+ if not tag:
+ return tag
+
+ if name == 'message':
+ return Message(node=tag)
+ return tag
+
class Presence(Protocol):
def __init__(self, to=None, typ=None, priority=None, show=None, status=None,
View it on GitLab: https://dev.gajim.org/gajim/python-nbxmpp/compare/4ce3016001112f7cc2c579bc2…
Philipp Hörist pushed to branch master at gajim / gajim
Commits:
a754c059 by Philipp Hörist at 2017-07-19T20:19:40+02:00
Fix discovery of MAM
- - - - -
5e1e4e27 by Philipp Hörist at 2017-07-20T01:58:08+02:00
Fix multiple metacontact requests at startup
_continue_connection_request_privacy() should only trigger
once after we received the discoinfo on the hostname.
We do a discoinfo on all items that the server offers,
_continue_connection_request_privacy() was triggered on every received
discoinfo again, hence requesting metacontacts and delimiters again.
also _continue_connection_request_privacy() was called on every
discoinfo error, instead of only on a hostname discoinfo error.
This bug is only triggered if the server doesnt support privacy rules.
- - - - -
96cbed4f by Philipp Hörist at 2017-07-20T01:58:41+02:00
Remove redundant source_remove()
We remove the source in _schedule_activity_timers()
- - - - -
2 changed files:
- gajim/chat_control.py
- gajim/common/connection.py
Changes:
=====================================
gajim/chat_control.py
=====================================
--- a/gajim/chat_control.py
+++ b/gajim/chat_control.py
@@ -910,8 +910,6 @@ class ChatControl(ChatControlBase):
chatstate_to_send = 'active'
contact.our_chatstate = 'active'
- GLib.source_remove(self.possible_paused_timeout_id)
- GLib.source_remove(self.possible_inactive_timeout_id)
self._schedule_activity_timers()
def _on_sent(obj, msg_stanza, message, encrypted, xhtml, label):
=====================================
gajim/common/connection.py
=====================================
--- a/gajim/common/connection.py
+++ b/gajim/common/connection.py
@@ -1811,8 +1811,10 @@ class Connection(CommonConnection, ConnectionHandlers):
# If we are not resuming, we ask for discovery info
# and archiving preferences
if not self.sm.supports_sm or (not self.sm.resuming and self.sm.enabled):
- self.discoverInfo(gajim.config.get_per('accounts', self.name,
- 'hostname'), id_prefix='Gajim_')
+ our_jid = gajim.get_jid_from_account(self.name)
+ our_server = gajim.config.get_per('accounts', self.name, 'hostname')
+ self.discoverInfo(our_jid, id_prefix='Gajim_')
+ self.discoverInfo(our_server, id_prefix='Gajim_')
self.sm.resuming = False # back to previous state
# Discover Stun server(s)
@@ -1865,7 +1867,8 @@ class Connection(CommonConnection, ConnectionHandlers):
def _nec_agent_info_error_received(self, obj):
if obj.conn.name != self.name:
return
- if obj.id_[:6] == 'Gajim_':
+ hostname = gajim.config.get_per('accounts', self.name, 'hostname')
+ if obj.id_[:6] == 'Gajim_' and obj.fjid == hostname:
self._continue_connection_request_privacy()
def _nec_agent_info_received(self, obj):
@@ -1891,6 +1894,19 @@ class Connection(CommonConnection, ConnectionHandlers):
if obj.id_[:6] == 'Gajim_':
hostname = gajim.config.get_per('accounts', self.name, 'hostname')
our_jid = gajim.get_jid_from_account(self.name)
+
+ if obj.fjid == our_jid:
+ if nbxmpp.NS_MAM_2 in obj.features:
+ self.archiving_namespace = nbxmpp.NS_MAM_2
+ elif nbxmpp.NS_MAM_1 in obj.features:
+ self.archiving_namespace = nbxmpp.NS_MAM_1
+ elif nbxmpp.NS_MAM in obj.features:
+ self.archiving_namespace = nbxmpp.NS_MAM
+ if self.archiving_namespace:
+ self.archiving_supported = True
+ self.archiving_313_supported = True
+ get_action(self.name + '-archive').set_enabled(True)
+
if obj.fjid == hostname:
if nbxmpp.NS_GMAILNOTIFY in obj.features:
gajim.gmail_domains.append(obj.fjid)
@@ -1915,16 +1931,6 @@ class Connection(CommonConnection, ConnectionHandlers):
# Remove stored bookmarks accessible to everyone.
self.send_pb_purge(our_jid, 'storage:bookmarks')
self.send_pb_delete(our_jid, 'storage:bookmarks')
- if nbxmpp.NS_MAM_2 in obj.features:
- self.archiving_namespace = nbxmpp.NS_MAM_2
- elif nbxmpp.NS_MAM_1 in obj.features:
- self.archiving_namespace = nbxmpp.NS_MAM_1
- elif nbxmpp.NS_MAM in obj.features:
- self.archiving_namespace = nbxmpp.NS_MAM
- if self.archiving_namespace:
- self.archiving_supported = True
- self.archiving_313_supported = True
- get_action(self.name + '-archive').set_enabled(True)
if nbxmpp.NS_ARCHIVE in obj.features:
self.archiving_supported = True
self.archiving_136_supported = True
@@ -1952,6 +1958,8 @@ class Connection(CommonConnection, ConnectionHandlers):
self.privacy_rules_supported = True
get_action(self.name + '-privacylists').set_enabled(True)
+ self._continue_connection_request_privacy()
+
if nbxmpp.NS_BYTESTREAM in obj.features and \
gajim.config.get_per('accounts', self.name, 'use_ft_proxies'):
our_fjid = helpers.parse_jid(our_jid + '/' + \
@@ -1968,7 +1976,6 @@ class Connection(CommonConnection, ConnectionHandlers):
self.available_transports[transport_type].append(obj.fjid)
else:
self.available_transports[transport_type] = [obj.fjid]
- self._continue_connection_request_privacy()
def send_custom_status(self, show, msg, jid):
if not show in gajim.SHOW_LIST:
View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/47c33bbe392fbdc54dfb898203a45eb02…