Skip to content
Snippets Groups Projects
Commit db05b124 authored by Philipp Hörist's avatar Philipp Hörist
Browse files

MUC: Adapt to nbxmpp changes

parent f9f6910e
No related branches found
No related tags found
No related merge requests found
......@@ -350,7 +350,7 @@ def kick(self, who, reason):
if who not in app.contacts.get_nick_list(self.account, self.room_jid):
raise CommandError(_("Nickname not found"))
self.connection.get_module('MUC').set_role(
self.room_jid, who, 'none', reason or str())
self.room_jid, who, 'none', reason)
@command(raw=True)
# Do not translate moderator, participant, visitor, none
......
......@@ -23,7 +23,6 @@
from nbxmpp.const import PresenceType
from nbxmpp.const import StatusCode
from nbxmpp.structs import StanzaHandler
from nbxmpp.util import is_error_result
from nbxmpp.errors import StanzaError
from gi.repository import GLib
......@@ -230,14 +229,16 @@ def configure_room(self, room_jid):
self._nbxmpp('MUC').request_config(room_jid,
callback=self._on_room_config)
def _on_room_config(self, result):
if is_error_result(result):
self._log.info(result)
def _on_room_config(self, task):
try:
result = task.finish()
except StanzaError as error:
self._log.info(error)
app.nec.push_incoming_event(NetworkEvent(
'muc-configuration-failed',
account=self._account,
room_jid=result.jid,
error=result))
room_jid=error.jid,
error=error))
return
self._log.info('Configure room: %s', result.jid)
......@@ -261,14 +262,16 @@ def _apply_config(form, config=None):
else:
field.value = value
def _on_config_result(self, result):
if is_error_result(result):
self._log.info(result)
def _on_config_result(self, task):
try:
result = task.finish()
except StanzaError as error:
self._log.info(error)
app.nec.push_incoming_event(NetworkEvent(
'muc-configuration-failed',
account=self._account,
room_jid=result.jid,
error=result))
room_jid=error.jid,
error=error))
return
self._con.get_module('Discovery').disco_muc(
......@@ -716,19 +719,19 @@ def send_captcha(self, room_jid, form_node):
form_node,
callback=self._on_captcha_result)
def _on_captcha_result(self, result):
if not is_error_result(result):
return
muc_data = self._manager.get(result.jid)
if muc_data is None:
return
self._manager.set_state(result.jid, MUCJoinedState.CAPTCHA_FAILED)
app.nec.push_incoming_event(
NetworkEvent('muc-captcha-error',
account=self._account,
room_jid=str(result.jid),
error_text=to_user_string(result)))
def _on_captcha_result(self, task):
try:
task.finish()
except StanzaError as error:
muc_data = self._manager.get(error.jid)
if muc_data is None:
return
self._manager.set_state(error.jid, MUCJoinedState.CAPTCHA_FAILED)
app.nec.push_incoming_event(
NetworkEvent('muc-captcha-error',
account=self._account,
room_jid=str(error.jid),
error_text=to_user_string(error)))
def _on_config_change(self, _con, _stanza, properties):
if not properties.is_muc_config_change:
......
......@@ -33,7 +33,7 @@
from nbxmpp.const import StatusCode
from nbxmpp.const import Affiliation
from nbxmpp.const import PresenceType
from nbxmpp.util import is_error_result
from nbxmpp.errors import StanzaError
from nbxmpp.modules.vcard_temp import VCard
from gi.repository import Gtk
......@@ -546,9 +546,11 @@ def _on_configure_room(self, _action, _param):
self.room_jid,
contact.affiliation.value)
def _on_configure_form_received(self, result):
if is_error_result(result):
log.info(result)
def _on_configure_form_received(self, task):
try:
result = task.finish()
except StanzaError as error:
log.info(error)
return
GroupchatConfig(self.account, result.jid, 'owner', result.form)
......
......@@ -15,7 +15,7 @@
import logging
from nbxmpp.namespaces import Namespace
from nbxmpp.util import is_error_result
from nbxmpp.errors import StanzaError
from gi.repository import Gdk
from gi.repository import Gtk
......@@ -26,7 +26,6 @@
from gajim.gtk.dialogs import ErrorDialog
from gajim.gtk.dataform import DataFormWidget
from gajim.gtk.util import get_builder
from gajim.gtk.util import ensure_not_destroyed
log = logging.getLogger('gajim.gtk.groupchat_config')
......@@ -353,11 +352,13 @@ def _set_affiliations(self):
con = app.connections[self.account]
con.get_module('MUC').set_affiliation(self.jid, diff_dict)
@ensure_not_destroyed
def _on_affiliations_received(self, result, affiliation):
if is_error_result(result):
def _on_affiliations_received(self, task):
affiliation = task.get_user_data()
try:
result = task.finish()
except StanzaError as error:
log.info('Error while requesting %s affiliations: %s',
affiliation, result.condition)
affiliation, error.condition)
return
if affiliation == 'outcast':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment