changeset c736e7a257be in /home/hg/repos/gajim
author: lovetox
branches: gajim_0.16
details:http://hg.gajim.org/gajim?cmd=changeset;node=c736e7a257be
description: add new event for gc after message stanza is built so it can be
modified by plugins
diffstat:
src/common/connection.py | 39 ++++++++++++++++++++++---------
src/common/connection_handlers_events.py | 7 +++++
2 files changed, 35 insertions(+), 11 deletions(-)
diffs (104 lines):
diff -r b1567f3877c9 -r c736e7a257be src/common/connection.py
--- a/src/common/connection.py Tue Aug 02 14:09:22 2016 +0100
+++ b/src/common/connection.py Fri Jun 24 20:12:37 2016 +0200
@@ -54,7 +54,8 @@
PlainConnectionEvent, PrivacyListReceivedEvent,
PrivacyListActiveDefaultEvent, \
PrivacyListsReceivedEvent, RegisterAgentInfoReceivedEvent,
NewAccountConnectedEvent, \
AccountCreatedEvent, AccountNotCreatedEvent, BeforeChangeShowEvent,
StanzaSentEvent, \
- StanzaReceivedEvent, MessageNotSentEvent, GPGTrustKeyEvent,
BadGPGPassphraseEvent
+ StanzaReceivedEvent, MessageNotSentEvent, GPGTrustKeyEvent,
BadGPGPassphraseEvent, \
+ GcStanzaMessageOutgoingEvent
from common.connection_handlers_events import InsecurePasswordEvent,
MessageSentEvent, \
NonAnonymousServerErrorEvent, Oauth2CredentialsRequiredEvent,
PasswordRequiredEvent, \
RosterReceivedEvent, SearchResultReceivedEvent
@@ -830,6 +831,8 @@
self._nec_message_outgoing)
gajim.ged.register_event_handler('gc-message-outgoing', ged.OUT_CORE,
self._nec_gc_message_outgoing)
+ gajim.ged.register_event_handler('gc-stanza-message-outgoing',
ged.OUT_CORE,
+ self._nec_gc_stanza_message_outgoing)
gajim.ged.register_event_handler('stanza-message-outgoing',
ged.OUT_CORE, self._nec_stanza_message_outgoing)
# END __init__
@@ -846,6 +849,8 @@
self._nec_message_outgoing)
gajim.ged.remove_event_handler('gc-message-outgoing', ged.OUT_CORE,
self._nec_gc_message_outgoing)
+ gajim.ged.remove_event_handler('gc-stanza-message-outgoing',
ged.OUT_CORE,
+ self._nec_gc_stanza_message_outgoing)
gajim.ged.remove_event_handler('stanza-message-outgoing', ged.OUT_CORE,
self._nec_stanza_message_outgoing)
@@ -2733,16 +2738,16 @@
if obj.correction_msg.getTag('replace'):
obj.correction_msg.delChild('replace')
obj.correction_msg.setTag('replace', attrs={'id': id_},
- namespace=nbxmpp.NS_CORRECT)
+ namespace=nbxmpp.NS_CORRECT)
id2 = self.connection.getAnID()
obj.correction_msg.setID(id2)
obj.correction_msg.setBody(obj.message)
if obj.xhtml:
obj.correction_msg.setXHTML(xhtml)
- obj.msg_id = self.connection.send(obj.correction_msg)
- gajim.nec.push_incoming_event(MessageSentEvent(None, conn=self,
- jid=obj.jid, message=obj.message, keyID=None, chatstate=None,
- automatic_message=obj.automatic_message, msg_id=obj.msg_id))
+ gajim.nec.push_incoming_event(GcStanzaMessageOutgoingEvent(
+ None, conn=self, automatic_message=obj.automatic_message,
+ jid=obj.jid, message=obj.message,
+ correction_msg=obj.correction_msg))
if obj.callback:
obj.callback(obj.correction_msg, obj.message)
return
@@ -2750,16 +2755,28 @@
from common.rst_xhtml_generator import create_xhtml
obj.xhtml = create_xhtml(obj.message)
msg_iq = nbxmpp.Message(obj.jid, obj.message, typ='groupchat',
- xhtml=obj.xhtml)
+ xhtml=obj.xhtml)
if obj.label is not None:
msg_iq.addChild(node=obj.label)
- obj.msg_id = self.connection.send(msg_iq)
- gajim.nec.push_incoming_event(MessageSentEvent(None, conn=self,
- jid=obj.jid, message=obj.message, keyID=None, chatstate=None,
- automatic_message=obj.automatic_message, msg_id=obj.msg_id))
+ gajim.nec.push_incoming_event(GcStanzaMessageOutgoingEvent(
+ None, conn=self, msg_iq=msg_iq,
+ automatic_message=obj.automatic_message,
+ jid=obj.jid, message=obj.message, correction_msg=None))
if obj.callback:
obj.callback(msg_iq, obj.message)
+ def _nec_gc_stanza_message_outgoing(self, obj):
+ if obj.conn.name != self.name:
+ return
+ if obj.correction_msg:
+ obj.msg_id = self.connection.send(obj.correction_msg)
+ else:
+ obj.msg_id = self.connection.send(obj.msg_iq)
+ gajim.nec.push_incoming_event(MessageSentEvent(
+ None, conn=self, jid=obj.jid, message=obj.message, keyID=None,
+ chatstate=None, automatic_message=obj.automatic_message,
+ msg_id=obj.msg_id))
+
def send_gc_subject(self, jid, subject):
if not gajim.account_is_connected(self.name):
return
diff -r b1567f3877c9 -r c736e7a257be src/common/connection_handlers_events.py
--- a/src/common/connection_handlers_events.py Tue Aug 02 14:09:22 2016 +0100
+++ b/src/common/connection_handlers_events.py Fri Jun 24 20:12:37 2016 +0200
@@ -2668,6 +2668,13 @@
def generate(self):
return True
+class GcStanzaMessageOutgoingEvent(nec.NetworkOutgoingEvent):
+ name='gc-stanza-message-outgoing'
+ base_network_events = []
+
+ def generate(self):
+ return True
+
class GcMessageOutgoingEvent(nec.NetworkOutgoingEvent):
name = 'gc-message-outgoing'
base_network_events = []
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits