Philipp Hörist pushed to branch master at gajim / python-nbxmpp
Commits:
9ccb310e by Philipp Hörist at 2019-10-13T17:56:50Z
Add Correction (XEP-0308) support
- - - - -
91c6dd86 by Philipp Hörist at 2019-10-13T18:16:58Z
Add Attention (XEP-0224) support
- - - - -
22ddb4b8 by Philipp Hörist at 2019-10-13T19:36:17Z
Add forms message attribute
- - - - -
6 changed files:
- nbxmpp/dispatcher.py
- + nbxmpp/modules/attention.py
- + nbxmpp/modules/correction.py
- nbxmpp/modules/message.py
- nbxmpp/protocol.py
- nbxmpp/structs.py
Changes:
=====================================
nbxmpp/dispatcher.py
=====================================
@@ -74,6 +74,8 @@ from nbxmpp.modules.discovery import Discovery
from nbxmpp.modules.chat_markers import ChatMarkers
from nbxmpp.modules.receipts import Receipts
from nbxmpp.modules.oob import OOB
+from nbxmpp.modules.correction import Correction
+from nbxmpp.modules.attention import Attention
from nbxmpp.modules.misc import unwrap_carbon
from nbxmpp.modules.misc import unwrap_mam
from nbxmpp.util import get_properties_struct
@@ -215,6 +217,8 @@ class XMPPDispatcher(PlugIn):
self._modules['ChatMarkers'] = ChatMarkers(self._owner)
self._modules['Receipts'] = Receipts(self._owner)
self._modules['OOB'] = OOB(self._owner)
+ self._modules['Correction'] = Correction(self._owner)
+ self._modules['Attention'] = Attention(self._owner)
for instance in self._modules.values():
for handler in instance.handlers:
=====================================
nbxmpp/modules/attention.py
=====================================
@@ -0,0 +1,51 @@
+# Copyright (C) 2018 Philipp Hörist <philipp AT hoerist.com>
+#
+# This file is part of nbxmpp.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 3
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; If not, see <http://www.gnu.org/licenses/>.
+
+import logging
+
+from nbxmpp.protocol import NS_ATTENTION
+from nbxmpp.protocol import NS_DELAY2
+from nbxmpp.structs import StanzaHandler
+
+log = logging.getLogger('nbxmpp.m.attention')
+
+
+class Attention:
+ def __init__(self, client):
+ self._client = client
+ self.handlers = [
+ StanzaHandler(name='message',
+ callback=self._process_message_attention,
+ ns=NS_ATTENTION,
+ priority=15),
+ ]
+
+ def _process_message_attention(self, _con, stanza, properties):
+ attention = stanza.getTag('attention', namespace=NS_ATTENTION)
+ if attention is None:
+ return
+
+ if properties.is_mam_message:
+ return
+
+ if properties.is_carbon_message and properties.carbon.is_sent:
+ return
+
+ if stanza.getTag('x', namespace=NS_DELAY2) is not None:
+ return
+
+ properties.attention = True
=====================================
nbxmpp/modules/correction.py
=====================================
@@ -0,0 +1,48 @@
+# Copyright (C) 2018 Philipp Hörist <philipp AT hoerist.com>
+#
+# This file is part of nbxmpp.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 3
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; If not, see <http://www.gnu.org/licenses/>.
+
+import logging
+
+from nbxmpp.protocol import NS_CORRECT
+from nbxmpp.structs import StanzaHandler
+from nbxmpp.structs import CorrectionData
+
+log = logging.getLogger('nbxmpp.m.correction')
+
+
+class Correction:
+ def __init__(self, client):
+ self._client = client
+ self.handlers = [
+ StanzaHandler(name='message',
+ callback=self._process_message_correction,
+ ns=NS_CORRECT,
+ priority=15),
+ ]
+
+ def _process_message_correction(self, _con, stanza, properties):
+ replace = stanza.getTag('replace', namespace=NS_CORRECT)
+ if replace is None:
+ return
+
+ id_ = replace.getAttr('id')
+ if id_ is None:
+ log.warning('Correcton without id attribute')
+ log.warning(stanza)
+ return
+
+ properties.correction = CorrectionData(id_)
=====================================
nbxmpp/modules/message.py
=====================================
@@ -18,6 +18,7 @@
import logging
from nbxmpp.protocol import NodeProcessed
+from nbxmpp.protocol import NS_DATA
from nbxmpp.structs import StanzaHandler
from nbxmpp.structs import StanzaIDData
from nbxmpp.util import error_factory
@@ -75,6 +76,9 @@ class BaseMessage:
properties.body = stanza.getBody()
properties.thread = stanza.getThread()
properties.subject = stanza.getSubject()
+ forms = stanza.getTags('x', namespace=NS_DATA)
+ if forms:
+ properties.forms = forms
@staticmethod
def _parse_type(stanza):
=====================================
nbxmpp/protocol.py
=====================================
@@ -1369,6 +1369,12 @@ class Message(Protocol):
if desc is not None:
oob.setTagData('desc', desc)
+ def setCorrection(self, id_):
+ self.setTag('replace', namespace=NS_CORRECT, attrs={'id': id_})
+
+ def setAttention(self):
+ self.setTag('attention', namespace=NS_ATTENTION)
+
class Presence(Protocol):
=====================================
nbxmpp/structs.py
=====================================
@@ -123,6 +123,8 @@ DiscoItem.__new__.__defaults__ = (None, None)
OOBData = namedtuple('OOBData', 'url desc')
+CorrectionData = namedtuple('CorrectionData', 'id')
+
class DiscoInfo(namedtuple('DiscoInfo', 'stanza identities features dataforms timestamp')):
@@ -548,6 +550,9 @@ class MessageProperties:
self.marker = None
self.receipt = None
self.oob = None
+ self.correction = None
+ self.attention = False
+ self.forms = None
@property
def has_user_delay(self):
@@ -632,6 +637,18 @@ class MessageProperties:
def is_oob(self):
return self.oob is not None
+ @property
+ def is_correction(self):
+ return self.correction is not None
+
+ @property
+ def has_attention(self):
+ return self.attention
+
+ @property
+ def has_forms(self):
+ return self.forms is not None
+
class IqProperties:
def __init__(self):
View it on GitLab: https://dev.gajim.org/gajim/python-nbxmpp/compare/af360130ec8655f9c947fc97b…
--
View it on GitLab: https://dev.gajim.org/gajim/python-nbxmpp/compare/af360130ec8655f9c947fc97b…
You're receiving this email because of your account on dev.gajim.org.
Philipp Hörist pushed to branch master at gajim / python-nbxmpp
Commits:
af360130 by Philipp Hörist at 2019-10-13T09:57:29Z
Add OOB (XEP-0066) support
- - - - -
4 changed files:
- nbxmpp/dispatcher.py
- + nbxmpp/modules/oob.py
- nbxmpp/protocol.py
- nbxmpp/structs.py
Changes:
=====================================
nbxmpp/dispatcher.py
=====================================
@@ -73,6 +73,7 @@ from nbxmpp.modules.ibb import IBB
from nbxmpp.modules.discovery import Discovery
from nbxmpp.modules.chat_markers import ChatMarkers
from nbxmpp.modules.receipts import Receipts
+from nbxmpp.modules.oob import OOB
from nbxmpp.modules.misc import unwrap_carbon
from nbxmpp.modules.misc import unwrap_mam
from nbxmpp.util import get_properties_struct
@@ -213,6 +214,7 @@ class XMPPDispatcher(PlugIn):
self._modules['Discovery'] = Discovery(self._owner)
self._modules['ChatMarkers'] = ChatMarkers(self._owner)
self._modules['Receipts'] = Receipts(self._owner)
+ self._modules['OOB'] = OOB(self._owner)
for instance in self._modules.values():
for handler in instance.handlers:
=====================================
nbxmpp/modules/oob.py
=====================================
@@ -0,0 +1,49 @@
+# Copyright (C) 2018 Philipp Hörist <philipp AT hoerist.com>
+#
+# This file is part of nbxmpp.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 3
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; If not, see <http://www.gnu.org/licenses/>.
+
+import logging
+
+from nbxmpp.protocol import NS_X_OOB
+from nbxmpp.structs import StanzaHandler
+from nbxmpp.structs import OOBData
+
+log = logging.getLogger('nbxmpp.m.oob')
+
+
+class OOB:
+ def __init__(self, client):
+ self._client = client
+ self.handlers = [
+ StanzaHandler(name='message',
+ callback=self._process_message_oob,
+ ns=NS_X_OOB,
+ priority=15),
+ ]
+
+ def _process_message_oob(self, _con, stanza, properties):
+ oob = stanza.getTag('x', namespace=NS_X_OOB)
+ if oob is None:
+ return
+
+ url = oob.getTagData('url')
+ if url is None:
+ log.warning('OOB data without url')
+ log.warning(stanza)
+ return
+
+ desc = oob.getTagData('desc')
+ properties.oob = OOBData(url, desc)
=====================================
nbxmpp/protocol.py
=====================================
@@ -1363,6 +1363,12 @@ class Message(Protocol):
def setReceiptReceived(self, id_):
self.setTag('received', namespace=NS_RECEIPTS, attrs={'id': id_})
+ def setOOB(self, url, desc=None):
+ oob = self.setTag('x', namespace=NS_X_OOB)
+ oob.setTagData('url', url)
+ if desc is not None:
+ oob.setTagData('desc', desc)
+
class Presence(Protocol):
=====================================
nbxmpp/structs.py
=====================================
@@ -121,6 +121,8 @@ DiscoItems = namedtuple('DiscoItems', 'jid node items')
DiscoItem = namedtuple('DiscoItem', 'jid name node')
DiscoItem.__new__.__defaults__ = (None, None)
+OOBData = namedtuple('OOBData', 'url desc')
+
class DiscoInfo(namedtuple('DiscoInfo', 'stanza identities features dataforms timestamp')):
@@ -545,6 +547,7 @@ class MessageProperties:
self.pgp_legacy = None
self.marker = None
self.receipt = None
+ self.oob = None
@property
def has_user_delay(self):
@@ -625,6 +628,10 @@ class MessageProperties:
def is_receipt(self):
return self.receipt is not None
+ @property
+ def is_oob(self):
+ return self.oob is not None
+
class IqProperties:
def __init__(self):
View it on GitLab: https://dev.gajim.org/gajim/python-nbxmpp/commit/af360130ec8655f9c947fc97be…
--
View it on GitLab: https://dev.gajim.org/gajim/python-nbxmpp/commit/af360130ec8655f9c947fc97be…
You're receiving this email because of your account on dev.gajim.org.
Philipp Hörist pushed to branch master at gajim / python-nbxmpp
Commits:
a15b98ae by Philipp Hörist at 2019-10-12T13:17:20Z
Add Receipts (XEP-0184) support
- - - - -
4 changed files:
- nbxmpp/dispatcher.py
- + nbxmpp/modules/receipts.py
- nbxmpp/protocol.py
- nbxmpp/structs.py
Changes:
=====================================
nbxmpp/dispatcher.py
=====================================
@@ -72,6 +72,7 @@ from nbxmpp.modules.adhoc import AdHoc
from nbxmpp.modules.ibb import IBB
from nbxmpp.modules.discovery import Discovery
from nbxmpp.modules.chat_markers import ChatMarkers
+from nbxmpp.modules.receipts import Receipts
from nbxmpp.modules.misc import unwrap_carbon
from nbxmpp.modules.misc import unwrap_mam
from nbxmpp.util import get_properties_struct
@@ -211,6 +212,7 @@ class XMPPDispatcher(PlugIn):
self._modules['IBB'] = IBB(self._owner)
self._modules['Discovery'] = Discovery(self._owner)
self._modules['ChatMarkers'] = ChatMarkers(self._owner)
+ self._modules['Receipts'] = Receipts(self._owner)
for instance in self._modules.values():
for handler in instance.handlers:
=====================================
nbxmpp/modules/receipts.py
=====================================
@@ -0,0 +1,51 @@
+# Copyright (C) 2018 Philipp Hörist <philipp AT hoerist.com>
+#
+# This file is part of nbxmpp.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 3
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; If not, see <http://www.gnu.org/licenses/>.
+
+import logging
+
+from nbxmpp.protocol import NS_RECEIPTS
+from nbxmpp.structs import StanzaHandler
+from nbxmpp.structs import ReceiptData
+
+log = logging.getLogger('nbxmpp.m.receipts')
+
+
+class Receipts:
+ def __init__(self, client):
+ self._client = client
+ self.handlers = [
+ StanzaHandler(name='message',
+ callback=self._process_message_receipt,
+ ns=NS_RECEIPTS,
+ priority=15),
+ ]
+
+ def _process_message_receipt(self, _con, stanza, properties):
+ request = stanza.getTag('request', namespace=NS_RECEIPTS)
+ if request is not None:
+ properties.receipt = ReceiptData(request.getName())
+ return
+
+ received = stanza.getTag('received', namespace=NS_RECEIPTS)
+ if received is not None:
+ id_ = received.getAttr('id')
+ if id_ is None:
+ log.warning('Receipt without id attr')
+ log.warning(stanza)
+ return
+
+ properties.receipt = ReceiptData(received.getName(), id_)
=====================================
nbxmpp/protocol.py
=====================================
@@ -1323,6 +1323,11 @@ class Message(Protocol):
"""
self.setTag('origin-id', namespace=NS_SID, attrs={'id': val})
+ def buildReceipt(self):
+ message = Message(to=self.getFrom().getBare(), typ=self.getType())
+ message.setReceiptReceived(self.getID())
+ return message
+
def buildReply(self, text=None):
"""
Builds and returns another message object with specified text. The to,
@@ -1352,6 +1357,12 @@ class Message(Protocol):
def setMarkable(self):
self.setTag('markable', namespace=NS_CHATMARKERS)
+ def setReceiptRequest(self):
+ self.setTag('request', namespace=NS_RECEIPTS)
+
+ def setReceiptReceived(self, id_):
+ self.setTag('received', namespace=NS_RECEIPTS, attrs={'id': id_})
+
class Presence(Protocol):
=====================================
nbxmpp/structs.py
=====================================
@@ -485,6 +485,22 @@ class CarbonData(namedtuple('MAMData', 'type')):
return self.type == 'received'
+class ReceiptData(namedtuple('ReceiptData', 'type id')):
+
+ __slots__ = []
+
+ def __new__(cls, type, id=None):
+ return super(ReceiptData, cls).__new__(cls, type, id)
+
+ @property
+ def is_request(self):
+ return self.type == 'request'
+
+ @property
+ def is_received(self):
+ return self.type == 'received'
+
+
class Properties:
pass
@@ -528,6 +544,7 @@ class MessageProperties:
self.encrypted = None
self.pgp_legacy = None
self.marker = None
+ self.receipt = None
@property
def has_user_delay(self):
@@ -604,6 +621,10 @@ class MessageProperties:
def is_marker(self):
return self.marker is not None
+ @property
+ def is_receipt(self):
+ return self.receipt is not None
+
class IqProperties:
def __init__(self):
View it on GitLab: https://dev.gajim.org/gajim/python-nbxmpp/commit/a15b98aec870e0e6c8fac08f10…
--
View it on GitLab: https://dev.gajim.org/gajim/python-nbxmpp/commit/a15b98aec870e0e6c8fac08f10…
You're receiving this email because of your account on dev.gajim.org.
Philipp Hörist pushed to branch master at gajim / gajim
Commits:
3de7d8f6 by Philipp Hörist at 2019-10-10T19:11:03Z
Groupchat: Show subject timestamp in preferred format
%c uses the preferred format on the current system
- - - - -
1 changed file:
- gajim/groupchat_control.py
Changes:
=====================================
gajim/groupchat_control.py
=====================================
@@ -1032,8 +1032,7 @@ class GroupchatControl(ChatControlBase):
'nick': event.nickname, 'subject': event.subject}
if event.user_timestamp:
- date = time.strftime('%d-%m-%Y %H:%M:%S',
- time.localtime(event.user_timestamp))
+ date = time.strftime('%c', time.localtime(event.user_timestamp))
text = '%s - %s' % (text, date)
if (app.config.get('show_subject_on_join') or
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/3de7d8f64134ac703ea31a9337169a1d18…
--
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/3de7d8f64134ac703ea31a9337169a1d18…
You're receiving this email because of your account on dev.gajim.org.
Philipp Hörist pushed to branch master at gajim / gajim
Commits:
22cb839e by Philipp Hörist at 2019-10-09T20:50:44Z
Autoscroll correctly to the end after sending a message
On some systems when an encrypted message was written and the lock
icon was displayed, the textview did not scroll to the end.
Fixes #9443
- - - - -
1 changed file:
- gajim/conversation_textview.py
Changes:
=====================================
gajim/conversation_textview.py
=====================================
@@ -368,7 +368,7 @@ class ConversationTextview(GObject.GObject):
def scroll_to_end(self, force=False):
if self.autoscroll or force:
- util.scroll_to_end(self.tv.get_parent())
+ GLib.idle_add(util.scroll_to_end, self.tv.get_parent())
def correct_message(self, correct_id, kind, name):
allowed = True
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/22cb839ed8076dbc992b3d447b580d0cb1…
--
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/22cb839ed8076dbc992b3d447b580d0cb1…
You're receiving this email because of your account on dev.gajim.org.