Philipp Hörist pushed to branch chat_markers at gajim / gajim
Commits:
f7fce220 by Philipp Hörist at 2019-10-01T21:44:06Z
remove not needed change
- - - - -
1 changed file:
- gajim/common/modules/message.py
Changes:
=====================================
gajim/common/modules/message.py
=====================================
@@ -173,7 +173,7 @@ class Message(BaseModule):
'timestamp': properties.timestamp,
'delayed': properties.user_timestamp is not None,
'muc_pm': properties.is_muc_pm,
- 'gc_control': gc_control,
+ 'gc_control': gc_control
}
app.nec.push_incoming_event(NetworkEvent('update-client-info',
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/f7fce2209a15072d3d05f621e68baf8da5…
--
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/f7fce2209a15072d3d05f621e68baf8da5…
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:
c0b49558 by Philipp Hörist at 2019-10-01T21:33:41Z
Add Chat Markers (XEP-0333) support
- - - - -
4 changed files:
- nbxmpp/dispatcher.py
- + nbxmpp/modules/chat_markers.py
- nbxmpp/protocol.py
- nbxmpp/structs.py
Changes:
=====================================
nbxmpp/dispatcher.py
=====================================
@@ -70,6 +70,7 @@ from nbxmpp.modules.software_version import SoftwareVersion
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.misc import unwrap_carbon
from nbxmpp.modules.misc import unwrap_mam
from nbxmpp.util import get_properties_struct
@@ -208,6 +209,7 @@ class XMPPDispatcher(PlugIn):
self._modules['AdHoc'] = AdHoc(self._owner)
self._modules['IBB'] = IBB(self._owner)
self._modules['Discovery'] = Discovery(self._owner)
+ self._modules['ChatMarkers'] = ChatMarkers(self._owner)
for instance in self._modules.values():
for handler in instance.handlers:
=====================================
nbxmpp/modules/chat_markers.py
=====================================
@@ -0,0 +1,53 @@
+# 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_CHATMARKERS
+from nbxmpp.structs import StanzaHandler
+from nbxmpp.structs import ChatMarker
+
+log = logging.getLogger('nbxmpp.m.chat_marker')
+
+
+class ChatMarkers:
+ def __init__(self, client):
+ self._client = client
+ self.handlers = [
+ StanzaHandler(name='message',
+ callback=self._process_message_marker,
+ ns=NS_CHATMARKERS,
+ priority=15),
+ ]
+
+ @staticmethod
+ def _process_message_marker(_con, stanza, properties):
+ type_ = stanza.getTag('received', NS_CHATMARKERS)
+ if type_ is not None:
+ type_ = stanza.getTag('displayed', NS_CHATMARKERS)
+ if type_ is None:
+ type_ = stanza.getTag('acknowledged', NS_CHATMARKERS)
+ if type_ is None:
+ return
+
+ id_ = type_.getAttr('id')
+ if id_ is None:
+ log.warning('Chatmarker without id')
+ log.warning(stanza)
+ return
+
+ properties.marker = ChatMarker(type_, id_)
=====================================
nbxmpp/protocol.py
=====================================
@@ -1346,6 +1346,13 @@ class Message(Protocol):
attrs.append(child.getAttr('code'))
return attrs
+ def setMarker(self, type_, id_):
+ self.setTag(type_, namespace=NS_CHATMARKERS, attrs={'id': id_})
+
+ def setMarkable(self):
+ self.setTag('markable', namespace=NS_CHATMARKERS)
+
+
class Presence(Protocol):
def __init__(self, to=None, typ=None, priority=None, show=None, status=None,
=====================================
nbxmpp/structs.py
=====================================
@@ -361,6 +361,21 @@ class OMEMOBundle(namedtuple('OMEMOBundle', 'spk spk_signature ik otpks')):
return random.SystemRandom().choice(self.otpks)
+class ChatMarker(namedtuple('ChatMarker', 'type id')):
+
+ @property
+ def is_received(self):
+ return self.type == 'received'
+
+ @property
+ def is_displayed(self):
+ return self.type == 'displayed'
+
+ @property
+ def is_acknowledged(self):
+ return self.type == 'acknowledged'
+
+
class CommonError:
def __init__(self, stanza):
self._error_node = stanza.getTag('error')
@@ -497,6 +512,7 @@ class MessageProperties:
self.omemo = None
self.encrypted = None
self.pgp_legacy = None
+ self.marker = None
@property
def has_user_delay(self):
@@ -565,6 +581,28 @@ class MessageProperties:
def is_self_message(self):
return self.self_message
+ @property
+ def is_marker(self):
+ return self.marker is not None
+
+ @property
+ def is_acknowledged_marker(self):
+ if self.marker is None:
+ return False
+ return self.marker.is_acknowledged
+
+ @property
+ def is_received_marker(self):
+ if self.marker is None:
+ return False
+ return self.marker.is_received
+
+ @property
+ def is_displayed_marker(self):
+ if self.marker is None:
+ return False
+ return self.marker.is_displayed
+
class IqProperties:
def __init__(self):
View it on GitLab: https://dev.gajim.org/gajim/python-nbxmpp/commit/c0b495584fcd26640e693503a3…
--
View it on GitLab: https://dev.gajim.org/gajim/python-nbxmpp/commit/c0b495584fcd26640e693503a3…
You're receiving this email because of your account on dev.gajim.org.
Philipp Hörist pushed to branch master at gajim / gajim
Commits:
5db3dc55 by Philipp Hörist at 2019-10-01T18:08:37Z
Fix LMC in when ChatControl is not open
When the ChatControl is not open we create a ChatEvent. The current
message id was not passed to ChatEvent. So on correction the
ConversationTextview could not find the messages it was supposed to correct
This adds a message_id attr to ChatEvent.
- - - - -
3 changed files:
- gajim/chat_control.py
- gajim/common/events.py
- gajim/session.py
Changes:
=====================================
gajim/chat_control.py
=====================================
@@ -1284,7 +1284,8 @@ class ChatControl(ChatControlBase):
self.add_message(event.message, kind, tim=event.time,
encrypted=event.encrypted, subject=event.subject,
xhtml=event.xhtml, displaymarking=event.displaymarking,
- correct_id=event.correct_id, additional_data=event.additional_data)
+ correct_id=event.correct_id, message_id=event.message_id,
+ additional_data=event.additional_data)
if isinstance(event.msg_log_id, int):
message_ids.append(event.msg_log_id)
=====================================
gajim/common/events.py
=====================================
@@ -62,7 +62,7 @@ class Event:
class ChatEvent(Event):
type_ = 'chat'
def __init__(self, message, subject, kind, time_, encrypted, resource,
- msg_log_id, correct_id=None, xhtml=None, session=None, form_node=None,
+ msg_log_id, correct_id=None, message_id=None, xhtml=None, session=None, form_node=None,
displaymarking=None, sent_forwarded=False, show_in_roster=False,
show_in_systray=True, additional_data=None):
Event.__init__(self, time_, show_in_roster=show_in_roster,
@@ -74,6 +74,7 @@ class ChatEvent(Event):
self.encrypted = encrypted
self.resource = resource
self.msg_log_id = msg_log_id
+ self.message_id = message_id
self.correct_id = correct_id
self.xhtml = xhtml
self.session = session
=====================================
gajim/session.py
=====================================
@@ -253,7 +253,9 @@ class ChatControlSession:
if do_event:
event = event_t(obj.msgtxt, obj.subject, obj.mtype, obj.timestamp,
obj.encrypted, obj.resource, obj.msg_log_id,
- correct_id=(obj.id_, obj.correct_id), xhtml=obj.xhtml,
+ correct_id=obj.correct_id,
+ message_id=obj.message_id,
+ xhtml=obj.xhtml,
session=self, form_node=obj.form_node,
displaymarking=obj.displaymarking,
sent_forwarded=obj.forwarded and obj.sent,
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/5db3dc55305b201722f9da74db732af98d…
--
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/5db3dc55305b201722f9da74db732af98d…
You're receiving this email because of your account on dev.gajim.org.
Yann Leboulanger pushed to branch chat_markers at gajim / gajim
Commits:
a90aa9eb by Yann Leboulanger at 2019-09-29T19:46:28Z
add missing chat_markers module
- - - - -
1 changed file:
- + gajim/common/modules/chat_markers.py
Changes:
=====================================
gajim/common/modules/chat_markers.py
=====================================
@@ -0,0 +1,40 @@
+# This file is part of Gajim.
+#
+# Gajim 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; version 3 only.
+#
+# Gajim 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 Gajim. If not, see <http://www.gnu.org/licenses/>.
+
+# Chat Markers (XEP-0333)
+#TODO: add <thread> support
+
+import nbxmpp
+
+from gajim.common.modules.base import BaseModule
+
+
+class ChatMarkers(BaseModule):
+ def __init__(self, con):
+ BaseModule.__init__(self, con)
+
+ def send_marker(self, jid, marker, id_, is_gc):
+ if is_gc:
+ message = nbxmpp.Message(to=jid, typ='groupchat')
+ else:
+ message = nbxmpp.Message(to=jid, typ='chat')
+ message.setTag(marker, namespace=nbxmpp.NS_CHATMARKERS,
+ attrs={'id': id_})
+ self._nbxmpp().send(message)
+
+ def send_displayed_marker(self, jid, id_, is_gc):
+ self.send_marker(jid, 'displayed', id_, is_gc)
+
+def get_instance(*args, **kwargs):
+ return ChatMarkers(*args, **kwargs), 'ChatMarkers'
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/a90aa9eba7af2a7eb19f56237b669e60bb…
--
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/a90aa9eba7af2a7eb19f56237b669e60bb…
You're receiving this email because of your account on dev.gajim.org.