summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/core.py18
-rw-r--r--src/core/handlers.py18
2 files changed, 36 insertions, 0 deletions
diff --git a/src/core/core.py b/src/core/core.py
index 4bb0725b..95adc067 100644
--- a/src/core/core.py
+++ b/src/core/core.py
@@ -208,6 +208,7 @@ class Core(object):
self.xmpp.add_event_handler("groupchat_subject",
self.on_groupchat_subject)
self.xmpp.add_event_handler("message", self.on_message)
+ self.xmpp.add_event_handler("receipt_received", self.on_receipt)
self.xmpp.add_event_handler("got_online", self.on_got_online)
self.xmpp.add_event_handler("got_offline", self.on_got_offline)
self.xmpp.add_event_handler("roster_update", self.on_roster_update)
@@ -277,6 +278,10 @@ class Core(object):
self.configuration_change_handlers = {"": []}
self.add_configuration_handler("create_gaps",
self.on_gaps_config_change)
+ self.add_configuration_handler("request_message_receipts",
+ self.on_request_receipts_config_change)
+ self.add_configuration_handler("ack_message_receipts",
+ self.on_ack_receipts_config_change)
self.add_configuration_handler("plugins_dir",
self.on_plugins_dir_config_change)
self.add_configuration_handler("plugins_conf_dir",
@@ -331,6 +336,18 @@ class Core(object):
if value.lower() == "false":
self.tabs = list(tab for tab in self.tabs if tab)
+ def on_request_receipts_config_change(self, option, value):
+ """
+ Called when the request_message_receipts option changes
+ """
+ self.xmpp.plugin['xep_0184'].auto_request = config.get(option, True)
+
+ def on_ack_receipts_config_change(self, option, value):
+ """
+ Called when the ack_message_receipts option changes
+ """
+ self.xmpp.plugin['xep_0184'].auto_ack = config.get(option, True)
+
def on_plugins_dir_config_change(self, option, value):
"""
Called when the plugins_dir option is changed
@@ -1850,6 +1867,7 @@ class Core(object):
on_status_codes = handlers.on_status_codes
on_groupchat_subject = handlers.on_groupchat_subject
on_data_form = handlers.on_data_form
+ on_receipt = handlers.on_receipt
on_attention = handlers.on_attention
room_error = handlers.room_error
outgoing_stanza = handlers.outgoing_stanza
diff --git a/src/core/handlers.py b/src/core/handlers.py
index 7ce14c65..58217e8f 100644
--- a/src/core/handlers.py
+++ b/src/core/handlers.py
@@ -59,6 +59,8 @@ def on_carbon_received(self, message):
else:
return
recv['to'] = self.xmpp.boundjid.full
+ if recv['receipt']:
+ return self.on_receipt(recv)
self.on_normal_message(recv)
def on_carbon_sent(self, message):
@@ -955,6 +957,22 @@ def on_groupchat_subject(self, message):
if self.get_tab_by_name(room_from, tabs.MucTab) is self.current_tab():
self.refresh_window()
+def on_receipt(self, message):
+ """
+ When a delivery receipt is received (XEP-0184)
+ """
+ jid = message['from']
+ msg_id = message['receipt']
+ if not msg_id:
+ return
+
+ conversation = self.get_tab_by_name(jid)
+ conversation = conversation or self.get_tab_by_name(jid.bare)
+ if not conversation:
+ return
+
+ conversation.ack_message(msg_id)
+
def on_data_form(self, message):
"""
When a data form is received