Commit 96454134 authored by Philipp Hörist's avatar Philipp Hörist

AdHoc: Adapt to nbxmpp changes

parent ebe2c2ba
......@@ -17,16 +17,16 @@
from gi.repository import Gtk
from nbxmpp.util import is_error_result
from nbxmpp.const import AdHocAction
from nbxmpp.modules import dataforms
from nbxmpp.errors import StanzaError
from nbxmpp.errors import MalformedStanzaError
from gajim.common import app
from gajim.common.i18n import _
from gajim.common.helpers import to_user_string
from gajim.gtk.dataform import DataFormWidget
from gajim.gtk.util import ensure_not_destroyed
from gajim.gtk.util import find_widget
from gajim.gtk.util import MultiLineLabel
......@@ -186,30 +186,25 @@ def _abort(self, *args):
command, AdHocAction.CANCEL)
self.set_current_page(Page.COMMANDS)
@ensure_not_destroyed
def _received_command_list(self, commands):
error_text = None
if is_error_result(commands):
error_text = to_user_string(commands)
elif not commands:
error_text = _('No commands available')
def _received_command_list(self, task):
try:
commands = task.finish()
except (StanzaError, MalformedStanzaError) as error:
self._set_error(to_user_string(error), False)
return
if error_text is not None:
self.get_nth_page(Page.ERROR).set_text(error_text)
self.get_nth_page(Page.ERROR).show_command_button = False
self.set_current_page(Page.ERROR)
if not commands:
self._set_error(_('No commands available'), False)
return
self.get_nth_page(Page.COMMANDS).add_commands(commands)
self.set_current_page(Page.COMMANDS)
@ensure_not_destroyed
def _received_stage(self, stage):
if is_error_result(stage):
self.get_nth_page(Page.ERROR).set_text(to_user_string(stage))
self.get_nth_page(Page.ERROR).show_command_button = True
self.set_current_page(Page.ERROR)
def _received_stage(self, task):
try:
stage = task.finish()
except (StanzaError, MalformedStanzaError) as error:
self._set_error(to_user_string(error), True)
return
page = Page.STAGE
......@@ -220,6 +215,11 @@ def _received_stage(self, stage):
stage_page.process_stage(stage)
self.set_current_page(page)
def _set_error(self, text, show_command_button):
self.get_nth_page(Page.ERROR).set_text(text)
self.get_nth_page(Page.ERROR).show_command_button = show_command_button
self.set_current_page(Page.ERROR)
def set_stage_complete(self, is_valid):
self._buttons['next'].set_sensitive(is_valid)
self._buttons['complete'].set_sensitive(is_valid)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment