summaryrefslogtreecommitdiff
path: root/src/core/core.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2014-04-14 22:32:34 +0200
committermathieui <mathieui@mathieui.net>2014-04-14 22:32:34 +0200
commit3221534b0f77a00043032c1e350814f607a56380 (patch)
tree6c7bd391e3c2e70c40efdb0c0249d676036899a3 /src/core/core.py
parent245f5f050cd1b72f365a21c57d3462ed5207e0cc (diff)
downloadpoezio-3221534b0f77a00043032c1e350814f607a56380.tar.gz
poezio-3221534b0f77a00043032c1e350814f607a56380.tar.bz2
poezio-3221534b0f77a00043032c1e350814f607a56380.tar.xz
poezio-3221534b0f77a00043032c1e350814f607a56380.zip
Implement XEP-0249 (Direct MUC Invitations)
- fallback to mediated invitations if only the bare jid is given to the command or if the jid does not advertise support TODO: provide a way to send passwords
Diffstat (limited to 'src/core/core.py')
-rw-r--r--src/core/core.py28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/core/core.py b/src/core/core.py
index 41cb9586..b41bb1a4 100644
--- a/src/core/core.py
+++ b/src/core/core.py
@@ -188,7 +188,8 @@ class Core(object):
self.xmpp.add_event_handler("session_start", self.on_session_start_features)
self.xmpp.add_event_handler("groupchat_presence", self.on_groupchat_presence)
self.xmpp.add_event_handler("groupchat_message", self.on_groupchat_message)
- self.xmpp.add_event_handler("groupchat_invite", self.on_groupchat_invite)
+ self.xmpp.add_event_handler("groupchat_invite", self.on_groupchat_invitation)
+ self.xmpp.add_event_handler("groupchat_direct_invite", self.on_groupchat_direct_invitation)
self.xmpp.add_event_handler("groupchat_decline", self.on_groupchat_decline)
self.xmpp.add_event_handler("groupchat_config_status", self.on_status_codes)
self.xmpp.add_event_handler("groupchat_subject", self.on_groupchat_subject)
@@ -705,6 +706,27 @@ class Core(object):
self.current_tab().command_say(msg)
return True
+ def invite(self, jid, room, reason=None):
+ """
+ Checks if the sender supports XEP-0249, then send an invitation,
+ or a mediated one if it does not.
+ TODO: allow passwords
+ """
+ def callback(iq):
+ if not iq:
+ return
+ if 'jabber:x:conference' in iq['disco_info'].get_features():
+ self.xmpp.plugin['xep_0249'].send_invitation(
+ jid,
+ room,
+ reason=reason)
+ else: # fallback
+ self.xmpp.plugin['xep_0045'].invite(room, jid,
+ reason=reason or '')
+
+ self.xmpp.plugin['xep_0030'].get_info(jid=jid, block=False,
+ timeout=5, callback=callback)
+
def get_error_message(self, stanza, deprecated=False):
"""
Takes a stanza of the form <message type='error'><error/></message>
@@ -1422,6 +1444,7 @@ class Core(object):
if not desc and shortdesc:
desc = shortdesc
self.commands[name] = Command(func, desc, completion, shortdesc, usage)
+
def register_initial_commands(self):
"""
Register the commands when poezio starts
@@ -1623,7 +1646,8 @@ class Core(object):
on_session_start_features = handlers.on_session_start_features
on_carbon_received = handlers.on_carbon_received
on_carbon_sent = handlers.on_carbon_sent
- on_groupchat_invite = handlers.on_groupchat_invite
+ on_groupchat_invitation = handlers.on_groupchat_invitation
+ on_groupchat_direct_invitation = handlers.on_groupchat_direct_invitation
on_groupchat_decline = handlers.on_groupchat_decline
on_message = handlers.on_message
on_normal_message = handlers.on_normal_message