| ... |
... |
@@ -17,16 +17,16 @@ |
|
17
|
17
|
|
|
18
|
18
|
from gi.repository import Gtk
|
|
19
|
19
|
|
|
20
|
|
-from nbxmpp.util import is_error_result
|
|
21
|
20
|
from nbxmpp.const import AdHocAction
|
|
22
|
21
|
from nbxmpp.modules import dataforms
|
|
|
22
|
+from nbxmpp.errors import StanzaError
|
|
|
23
|
+from nbxmpp.errors import MalformedStanzaError
|
|
23
|
24
|
|
|
24
|
25
|
from gajim.common import app
|
|
25
|
26
|
from gajim.common.i18n import _
|
|
26
|
27
|
from gajim.common.helpers import to_user_string
|
|
27
|
28
|
|
|
28
|
29
|
from gajim.gtk.dataform import DataFormWidget
|
|
29
|
|
-from gajim.gtk.util import ensure_not_destroyed
|
|
30
|
30
|
from gajim.gtk.util import find_widget
|
|
31
|
31
|
from gajim.gtk.util import MultiLineLabel
|
|
32
|
32
|
|
| ... |
... |
@@ -186,30 +186,25 @@ def _abort(self, *args): |
|
186
|
186
|
command, AdHocAction.CANCEL)
|
|
187
|
187
|
self.set_current_page(Page.COMMANDS)
|
|
188
|
188
|
|
|
189
|
|
- @ensure_not_destroyed
|
|
190
|
|
- def _received_command_list(self, commands):
|
|
191
|
|
- error_text = None
|
|
192
|
|
- if is_error_result(commands):
|
|
193
|
|
- error_text = to_user_string(commands)
|
|
194
|
|
-
|
|
195
|
|
- elif not commands:
|
|
196
|
|
- error_text = _('No commands available')
|
|
|
189
|
+ def _received_command_list(self, task):
|
|
|
190
|
+ try:
|
|
|
191
|
+ commands = task.finish()
|
|
|
192
|
+ except (StanzaError, MalformedStanzaError) as error:
|
|
|
193
|
+ self._set_error(to_user_string(error), False)
|
|
|
194
|
+ return
|
|
197
|
195
|
|
|
198
|
|
- if error_text is not None:
|
|
199
|
|
- self.get_nth_page(Page.ERROR).set_text(error_text)
|
|
200
|
|
- self.get_nth_page(Page.ERROR).show_command_button = False
|
|
201
|
|
- self.set_current_page(Page.ERROR)
|
|
|
196
|
+ if not commands:
|
|
|
197
|
+ self._set_error(_('No commands available'), False)
|
|
202
|
198
|
return
|
|
203
|
199
|
|
|
204
|
200
|
self.get_nth_page(Page.COMMANDS).add_commands(commands)
|
|
205
|
201
|
self.set_current_page(Page.COMMANDS)
|
|
206
|
202
|
|
|
207
|
|
- @ensure_not_destroyed
|
|
208
|
|
- def _received_stage(self, stage):
|
|
209
|
|
- if is_error_result(stage):
|
|
210
|
|
- self.get_nth_page(Page.ERROR).set_text(to_user_string(stage))
|
|
211
|
|
- self.get_nth_page(Page.ERROR).show_command_button = True
|
|
212
|
|
- self.set_current_page(Page.ERROR)
|
|
|
203
|
+ def _received_stage(self, task):
|
|
|
204
|
+ try:
|
|
|
205
|
+ stage = task.finish()
|
|
|
206
|
+ except (StanzaError, MalformedStanzaError) as error:
|
|
|
207
|
+ self._set_error(to_user_string(error), True)
|
|
213
|
208
|
return
|
|
214
|
209
|
|
|
215
|
210
|
page = Page.STAGE
|
| ... |
... |
@@ -220,6 +215,11 @@ def _received_stage(self, stage): |
|
220
|
215
|
stage_page.process_stage(stage)
|
|
221
|
216
|
self.set_current_page(page)
|
|
222
|
217
|
|
|
|
218
|
+ def _set_error(self, text, show_command_button):
|
|
|
219
|
+ self.get_nth_page(Page.ERROR).set_text(text)
|
|
|
220
|
+ self.get_nth_page(Page.ERROR).show_command_button = show_command_button
|
|
|
221
|
+ self.set_current_page(Page.ERROR)
|
|
|
222
|
+
|
|
223
|
223
|
def set_stage_complete(self, is_valid):
|
|
224
|
224
|
self._buttons['next'].set_sensitive(is_valid)
|
|
225
|
225
|
self._buttons['complete'].set_sensitive(is_valid)
|