Provide our own (non-blocking) wrappers for room configuration functions

This commit is contained in:
mathieui 2014-05-06 00:17:22 +02:00
parent 467ae18290
commit 16276cd163
2 changed files with 22 additions and 2 deletions

View file

@ -175,3 +175,23 @@ def set_user_affiliation(xmpp, muc_jid, affiliation, nick=None, jid=None, reason
import traceback import traceback
log.debug('Error setting the affiliation: %s', traceback.format_exc()) log.debug('Error setting the affiliation: %s', traceback.format_exc())
return False return False
def cancel_config(xmpp, room):
query = ET.Element('{http://jabber.org/protocol/muc#owner}query')
x = ET.Element('{jabber:x:data}x', type='cancel')
query.append(x)
iq = xmpp.makeIqSet(query)
iq['to'] = room
iq.send(block=False)
def configure_room(xmpp, room, form):
if form is None:
return
iq = xmpp.makeIqSet()
iq['to'] = room
query = ET.Element('{http://jabber.org/protocol/muc#owner}query')
form = form.getXML('submit')
query.append(form)
iq.append(query)
iq.send(block=False)

View file

@ -372,14 +372,14 @@ class MucTab(ChatTab):
""" """
The user do not want to send his/her config, send an iq cancel The user do not want to send his/her config, send an iq cancel
""" """
self.core.xmpp.plugin['xep_0045'].cancelConfig(self.name) muc.cancel_config(self.core.xmpp, self.name)
self.core.close_tab() self.core.close_tab()
def send_config(self, form): def send_config(self, form):
""" """
The user sends his/her config to the server The user sends his/her config to the server
""" """
self.core.xmpp.plugin['xep_0045'].configureRoom(self.name, form) muc.configure_room(self.core.xmpp, self.name, form)
self.core.close_tab() self.core.close_tab()
def command_cycle(self, arg): def command_cycle(self, arg):