Philipp Hörist pushed to branch master at gajim / gajim

Commits:

4 changed files:

Changes:

  • gajim/command_system/implementation/standard.py
    ... ... @@ -350,7 +350,7 @@ def kick(self, who, reason):
    350 350
             if who not in app.contacts.get_nick_list(self.account, self.room_jid):
    
    351 351
                 raise CommandError(_("Nickname not found"))
    
    352 352
             self.connection.get_module('MUC').set_role(
    
    353
    -            self.room_jid, who, 'none', reason or str())
    
    353
    +            self.room_jid, who, 'none', reason)
    
    354 354
     
    
    355 355
         @command(raw=True)
    
    356 356
         # Do not translate moderator, participant, visitor, none
    

  • gajim/common/modules/muc.py
    ... ... @@ -23,7 +23,6 @@
    23 23
     from nbxmpp.const import PresenceType
    
    24 24
     from nbxmpp.const import StatusCode
    
    25 25
     from nbxmpp.structs import StanzaHandler
    
    26
    -from nbxmpp.util import is_error_result
    
    27 26
     from nbxmpp.errors import StanzaError
    
    28 27
     
    
    29 28
     from gi.repository import GLib
    
    ... ... @@ -230,14 +229,16 @@ def configure_room(self, room_jid):
    230 229
             self._nbxmpp('MUC').request_config(room_jid,
    
    231 230
                                                callback=self._on_room_config)
    
    232 231
     
    
    233
    -    def _on_room_config(self, result):
    
    234
    -        if is_error_result(result):
    
    235
    -            self._log.info(result)
    
    232
    +    def _on_room_config(self, task):
    
    233
    +        try:
    
    234
    +            result = task.finish()
    
    235
    +        except StanzaError as error:
    
    236
    +            self._log.info(error)
    
    236 237
                 app.nec.push_incoming_event(NetworkEvent(
    
    237 238
                     'muc-configuration-failed',
    
    238 239
                     account=self._account,
    
    239
    -                room_jid=result.jid,
    
    240
    -                error=result))
    
    240
    +                room_jid=error.jid,
    
    241
    +                error=error))
    
    241 242
                 return
    
    242 243
     
    
    243 244
             self._log.info('Configure room: %s', result.jid)
    
    ... ... @@ -261,14 +262,16 @@ def _apply_config(form, config=None):
    261 262
                 else:
    
    262 263
                     field.value = value
    
    263 264
     
    
    264
    -    def _on_config_result(self, result):
    
    265
    -        if is_error_result(result):
    
    266
    -            self._log.info(result)
    
    265
    +    def _on_config_result(self, task):
    
    266
    +        try:
    
    267
    +            result = task.finish()
    
    268
    +        except StanzaError as error:
    
    269
    +            self._log.info(error)
    
    267 270
                 app.nec.push_incoming_event(NetworkEvent(
    
    268 271
                     'muc-configuration-failed',
    
    269 272
                     account=self._account,
    
    270
    -                room_jid=result.jid,
    
    271
    -                error=result))
    
    273
    +                room_jid=error.jid,
    
    274
    +                error=error))
    
    272 275
                 return
    
    273 276
     
    
    274 277
             self._con.get_module('Discovery').disco_muc(
    
    ... ... @@ -716,19 +719,19 @@ def send_captcha(self, room_jid, form_node):
    716 719
                                              form_node,
    
    717 720
                                              callback=self._on_captcha_result)
    
    718 721
     
    
    719
    -    def _on_captcha_result(self, result):
    
    720
    -        if not is_error_result(result):
    
    721
    -            return
    
    722
    -
    
    723
    -        muc_data = self._manager.get(result.jid)
    
    724
    -        if muc_data is None:
    
    725
    -            return
    
    726
    -        self._manager.set_state(result.jid, MUCJoinedState.CAPTCHA_FAILED)
    
    727
    -        app.nec.push_incoming_event(
    
    728
    -            NetworkEvent('muc-captcha-error',
    
    729
    -                         account=self._account,
    
    730
    -                         room_jid=str(result.jid),
    
    731
    -                         error_text=to_user_string(result)))
    
    722
    +    def _on_captcha_result(self, task):
    
    723
    +        try:
    
    724
    +            task.finish()
    
    725
    +        except StanzaError as error:
    
    726
    +            muc_data = self._manager.get(error.jid)
    
    727
    +            if muc_data is None:
    
    728
    +                return
    
    729
    +            self._manager.set_state(error.jid, MUCJoinedState.CAPTCHA_FAILED)
    
    730
    +            app.nec.push_incoming_event(
    
    731
    +                NetworkEvent('muc-captcha-error',
    
    732
    +                             account=self._account,
    
    733
    +                             room_jid=str(error.jid),
    
    734
    +                             error_text=to_user_string(error)))
    
    732 735
     
    
    733 736
         def _on_config_change(self, _con, _stanza, properties):
    
    734 737
             if not properties.is_muc_config_change:
    

  • gajim/groupchat_control.py
    ... ... @@ -33,7 +33,7 @@
    33 33
     from nbxmpp.const import StatusCode
    
    34 34
     from nbxmpp.const import Affiliation
    
    35 35
     from nbxmpp.const import PresenceType
    
    36
    -from nbxmpp.util import is_error_result
    
    36
    +from nbxmpp.errors import StanzaError
    
    37 37
     from nbxmpp.modules.vcard_temp import VCard
    
    38 38
     
    
    39 39
     from gi.repository import Gtk
    
    ... ... @@ -546,9 +546,11 @@ def _on_configure_room(self, _action, _param):
    546 546
                                 self.room_jid,
    
    547 547
                                 contact.affiliation.value)
    
    548 548
     
    
    549
    -    def _on_configure_form_received(self, result):
    
    550
    -        if is_error_result(result):
    
    551
    -            log.info(result)
    
    549
    +    def _on_configure_form_received(self, task):
    
    550
    +        try:
    
    551
    +            result = task.finish()
    
    552
    +        except StanzaError as error:
    
    553
    +            log.info(error)
    
    552 554
                 return
    
    553 555
             GroupchatConfig(self.account, result.jid, 'owner', result.form)
    
    554 556
     
    

  • gajim/gtk/groupchat_config.py
    ... ... @@ -15,7 +15,7 @@
    15 15
     import logging
    
    16 16
     
    
    17 17
     from nbxmpp.namespaces import Namespace
    
    18
    -from nbxmpp.util import is_error_result
    
    18
    +from nbxmpp.errors import StanzaError
    
    19 19
     from gi.repository import Gdk
    
    20 20
     from gi.repository import Gtk
    
    21 21
     
    
    ... ... @@ -26,7 +26,6 @@
    26 26
     from gajim.gtk.dialogs import ErrorDialog
    
    27 27
     from gajim.gtk.dataform import DataFormWidget
    
    28 28
     from gajim.gtk.util import get_builder
    
    29
    -from gajim.gtk.util import ensure_not_destroyed
    
    30 29
     
    
    31 30
     log = logging.getLogger('gajim.gtk.groupchat_config')
    
    32 31
     
    
    ... ... @@ -353,11 +352,13 @@ def _set_affiliations(self):
    353 352
             con = app.connections[self.account]
    
    354 353
             con.get_module('MUC').set_affiliation(self.jid, diff_dict)
    
    355 354
     
    
    356
    -    @ensure_not_destroyed
    
    357
    -    def _on_affiliations_received(self, result, affiliation):
    
    358
    -        if is_error_result(result):
    
    355
    +    def _on_affiliations_received(self, task):
    
    356
    +        affiliation = task.get_user_data()
    
    357
    +        try:
    
    358
    +            result = task.finish()
    
    359
    +        except StanzaError as error:
    
    359 360
                 log.info('Error while requesting %s affiliations: %s',
    
    360
    -                     affiliation, result.condition)
    
    361
    +                     affiliation, error.condition)
    
    361 362
                 return
    
    362 363
     
    
    363 364
             if affiliation == 'outcast':