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

Commits:

15 changed files:

Changes:

  • gajim/common/helpers.py
    ... ... @@ -70,6 +70,7 @@ from gajim.common import configpaths
    70 70
     from gajim.common.i18n import Q_
    
    71 71
     from gajim.common.i18n import _
    
    72 72
     from gajim.common.i18n import ngettext
    
    73
    +from gajim.common.i18n import get_rfc5646_lang
    
    73 74
     from gajim.common.const import ShowConstant
    
    74 75
     from gajim.common.const import Display
    
    75 76
     from gajim.common.const import URIType
    
    ... ... @@ -1613,3 +1614,14 @@ def validate_jid(jid):
    1613 1614
             return JID(str(jid))
    
    1614 1615
         except InvalidJid as error:
    
    1615 1616
             raise ValueError(error)
    
    1617
    +
    
    1618
    +
    
    1619
    +def to_user_string(error):
    
    1620
    +    text = error.get_text(get_rfc5646_lang())
    
    1621
    +    if text:
    
    1622
    +        return text
    
    1623
    +
    
    1624
    +    condition = error.condition
    
    1625
    +    if error.app_condition is not None:
    
    1626
    +        return '%s (%s)' % (condition, error.app_condition)
    
    1627
    +    return condition

  • gajim/common/modules/blocking.py
    ... ... @@ -64,7 +64,7 @@ class Blocking(BaseModule):
    64 64
     
    
    65 65
         def _blocking_list_received(self, result):
    
    66 66
             if is_error_result(result):
    
    67
    -            self._log.info('Error: %s', result)
    
    67
    +            self._log.info(result)
    
    68 68
                 return
    
    69 69
     
    
    70 70
             self.blocked = result.blocking_list
    

  • gajim/common/modules/bookmarks.py
    ... ... @@ -161,7 +161,7 @@ class Bookmarks(BaseModule):
    161 161
     
    
    162 162
         def _bookmarks_received(self, bookmarks):
    
    163 163
             if is_error_result(bookmarks):
    
    164
    -            self._log.info('Error: %s', bookmarks)
    
    164
    +            self._log.info(bookmarks)
    
    165 165
                 bookmarks = []
    
    166 166
     
    
    167 167
             self._request_in_progress = False
    

  • gajim/common/modules/discovery.py
    ... ... @@ -212,7 +212,7 @@ class Discovery(BaseModule):
    212 212
     
    
    213 213
         def _muc_info_response(self, result, callback):
    
    214 214
             if is_error_result(result):
    
    215
    -            if result.type == 'item-not-found':
    
    215
    +            if result.condition == 'item-not-found':
    
    216 216
                     # Groupchat does not exist
    
    217 217
                     self._log.info('MUC does not exist: %s', result.jid)
    
    218 218
                     callback()
    

  • gajim/common/modules/ibb.py
    ... ... @@ -22,6 +22,7 @@ from nbxmpp.structs import StanzaHandler
    22 22
     from nbxmpp.util import is_error_result
    
    23 23
     
    
    24 24
     from gajim.common import app
    
    25
    +from gajim.common.helpers import to_user_string
    
    25 26
     from gajim.common.modules.base import BaseModule
    
    26 27
     from gajim.common.file_props import FilesProp
    
    27 28
     
    
    ... ... @@ -149,8 +150,8 @@ class IBB(BaseModule):
    149 150
     
    
    150 151
         def _on_open_result(self, result, file_props):
    
    151 152
             if is_error_result(result):
    
    152
    -            app.socks5queue.error_cb('Error', str(result))
    
    153
    -            self._log.warning('Error: %s', result)
    
    153
    +            app.socks5queue.error_cb('Error', to_user_string(result))
    
    154
    +            self._log.warning(result)
    
    154 155
                 return
    
    155 156
             self.send_data(file_props)
    
    156 157
     
    
    ... ... @@ -183,8 +184,8 @@ class IBB(BaseModule):
    183 184
     
    
    184 185
         def _on_close_result(self, result):
    
    185 186
             if is_error_result(result):
    
    186
    -            app.socks5queue.error_cb('Error', str(result))
    
    187
    -            self._log.warning('Error: %s', result)
    
    187
    +            app.socks5queue.error_cb('Error', to_user_string(result))
    
    188
    +            self._log.warning(result)
    
    188 189
                 return
    
    189 190
     
    
    190 191
         def send_data(self, file_props):
    
    ... ... @@ -217,8 +218,8 @@ class IBB(BaseModule):
    217 218
     
    
    218 219
         def _on_data_result(self, result, file_props):
    
    219 220
             if is_error_result(result):
    
    220
    -            app.socks5queue.error_cb('Error', str(result))
    
    221
    -            self._log.warning('Error: %s', result)
    
    221
    +            app.socks5queue.error_cb('Error', to_user_string(result))
    
    222
    +            self._log.warning(result)
    
    222 223
                 return
    
    223 224
             self.send_data(file_props)
    
    224 225
     
    

  • gajim/common/modules/muc.py
    ... ... @@ -38,6 +38,7 @@ from gajim.common.const import SyncThreshold
    38 38
     from gajim.common.helpers import AdditionalDataDict
    
    39 39
     from gajim.common.helpers import get_default_muc_config
    
    40 40
     from gajim.common.helpers import get_sync_threshold
    
    41
    +from gajim.common.helpers import to_user_string
    
    41 42
     from gajim.common import idle
    
    42 43
     from gajim.common.caps_cache import muc_caps_cache
    
    43 44
     from gajim.common.nec import NetworkEvent
    
    ... ... @@ -181,7 +182,7 @@ class MUC(BaseModule):
    181 182
     
    
    182 183
         def _on_room_config(self, result):
    
    183 184
             if is_error_result(result):
    
    184
    -            self._log.info('Error: %s', result)
    
    185
    +            self._log.info(result)
    
    185 186
                 app.nec.push_incoming_event(NetworkEvent(
    
    186 187
                     'muc-configuration-failed',
    
    187 188
                     account=self._account,
    
    ... ... @@ -212,7 +213,7 @@ class MUC(BaseModule):
    212 213
     
    
    213 214
         def _on_config_result(self, result):
    
    214 215
             if is_error_result(result):
    
    215
    -            self._log.info('Error: %s', result)
    
    216
    +            self._log.info(result)
    
    216 217
                 app.nec.push_incoming_event(NetworkEvent(
    
    217 218
                     'muc-configuration-failed',
    
    218 219
                     account=self._account,
    
    ... ... @@ -657,7 +658,7 @@ class MUC(BaseModule):
    657 658
                 NetworkEvent('muc-captcha-error',
    
    658 659
                              account=self._account,
    
    659 660
                              room_jid=str(result.jid),
    
    660
    -                         error_text=result.message))
    
    661
    +                         error_text=to_user_string(result)))
    
    661 662
     
    
    662 663
         def _on_config_change(self, _con, _stanza, properties):
    
    663 664
             if not properties.is_muc_config_change:
    

  • gajim/common/modules/user_avatar.py
    ... ... @@ -63,7 +63,7 @@ class UserAvatar(BaseModule):
    63 63
     
    
    64 64
         def _avatar_received(self, result):
    
    65 65
             if is_error_result(result):
    
    66
    -            self._log.info('Error: %s', result)
    
    66
    +            self._log.info(result)
    
    67 67
                 return
    
    68 68
     
    
    69 69
             self._log.info('Received Avatar: %s %s', result.jid, result.sha)
    

  • gajim/groupchat_control.py
    ... ... @@ -671,7 +671,7 @@ class GroupchatControl(ChatControlBase):
    671 671
     
    
    672 672
         def _on_configure_form_received(self, result):
    
    673 673
             if is_error_result(result):
    
    674
    -            log.info('Error %s %s', result.jid, result)
    
    674
    +            log.info(result)
    
    675 675
                 return
    
    676 676
             GroupchatConfig(self.account, result.jid, 'owner', result.form)
    
    677 677
     
    

  • gajim/gtk/adhoc.py
    ... ... @@ -23,6 +23,7 @@ from nbxmpp.modules import dataforms
    23 23
     
    
    24 24
     from gajim.common import app
    
    25 25
     from gajim.common.i18n import _
    
    26
    +from gajim.common.helpers import to_user_string
    
    26 27
     
    
    27 28
     from gajim.gtk.dataform import DataFormWidget
    
    28 29
     from gajim.gtk.util import ensure_not_destroyed
    
    ... ... @@ -189,7 +190,7 @@ class AdHocCommand(Gtk.Assistant):
    189 190
         def _received_command_list(self, commands):
    
    190 191
             error_text = None
    
    191 192
             if is_error_result(commands):
    
    192
    -            error_text = str(commands)
    
    193
    +            error_text = to_user_string(commands)
    
    193 194
     
    
    194 195
             elif not commands:
    
    195 196
                 error_text = _('No commands available')
    
    ... ... @@ -206,7 +207,7 @@ class AdHocCommand(Gtk.Assistant):
    206 207
         @ensure_not_destroyed
    
    207 208
         def _received_stage(self, stage):
    
    208 209
             if is_error_result(stage):
    
    209
    -            self.get_nth_page(Page.ERROR).set_text(str(stage))
    
    210
    +            self.get_nth_page(Page.ERROR).set_text(to_user_string(stage))
    
    210 211
                 self.get_nth_page(Page.ERROR).show_command_button = True
    
    211 212
                 self.set_current_page(Page.ERROR)
    
    212 213
                 return
    

  • gajim/gtk/blocking.py
    ... ... @@ -21,6 +21,7 @@ from gi.repository import GLib
    21 21
     
    
    22 22
     from gajim.common import app
    
    23 23
     from gajim.common.i18n import _
    
    24
    +from gajim.common.helpers import to_user_string
    
    24 25
     
    
    25 26
     from gajim.gtk.util import get_builder
    
    26 27
     from gajim.gtk.dialogs import HigDialog
    
    ... ... @@ -69,7 +70,7 @@ class BlockingList(Gtk.ApplicationWindow):
    69 70
             dialog = HigDialog(
    
    70 71
                 self, Gtk.MessageType.INFO, Gtk.ButtonsType.OK,
    
    71 72
                 _('Error!'),
    
    72
    -            GLib.markup_escape_text(str(error)))
    
    73
    +            GLib.markup_escape_text(error))
    
    73 74
             dialog.popup()
    
    74 75
     
    
    75 76
         def _on_blocking_list_received(self, result):
    
    ... ... @@ -78,7 +79,7 @@ class BlockingList(Gtk.ApplicationWindow):
    78 79
             self._set_grid_state(not is_error)
    
    79 80
     
    
    80 81
             if is_error:
    
    81
    -            self._show_error(result)
    
    82
    +            self._show_error(to_user_string(result))
    
    82 83
     
    
    83 84
             else:
    
    84 85
                 self._prev_blocked_jids = set(result.blocking_list)
    
    ... ... @@ -89,7 +90,7 @@ class BlockingList(Gtk.ApplicationWindow):
    89 90
         def _on_save_result(self, result):
    
    90 91
             self._await_results -= 1
    
    91 92
             if is_error_result(result) and not self._received_errors:
    
    92
    -            self._show_error(result)
    
    93
    +            self._show_error(to_user_string(result))
    
    93 94
                 self._received_errors = True
    
    94 95
     
    
    95 96
             if not self._await_results:
    

  • gajim/gtk/groupchat_config.py
    ... ... @@ -357,7 +357,7 @@ class GroupchatConfig(Gtk.ApplicationWindow):
    357 357
         def _on_affiliations_received(self, result, affiliation):
    
    358 358
             if is_error_result(result):
    
    359 359
                 log.info('Error while requesting %s affiliations: %s',
    
    360
    -                     affiliation, result)
    
    360
    +                     affiliation, result.condition)
    
    361 361
                 return
    
    362 362
     
    
    363 363
             if affiliation == 'outcast':
    

  • gajim/gtk/groupchat_creation.py
    ... ... @@ -25,6 +25,7 @@ from gajim.common.const import MUC_CREATION_EXAMPLES
    25 25
     from gajim.common.const import MUC_DISCO_ERRORS
    
    26 26
     from gajim.common.i18n import _
    
    27 27
     from gajim.common.helpers import validate_jid
    
    28
    +from gajim.common.helpers import to_user_string
    
    28 29
     
    
    29 30
     from gajim.gtk.dialogs import ErrorDialog
    
    30 31
     from gajim.gtk.util import get_builder
    
    ... ... @@ -158,7 +159,7 @@ class CreateGroupchatWindow(Gtk.ApplicationWindow):
    158 159
             self._ui.create_button.set_sensitive(False)
    
    159 160
     
    
    160 161
         def _set_warning_from_error(self, error):
    
    161
    -        text = MUC_DISCO_ERRORS.get(error.type, str(error))
    
    162
    +        text = MUC_DISCO_ERRORS.get(error.condition, to_user_string(error))
    
    162 163
             self._set_warning(text)
    
    163 164
     
    
    164 165
         def _set_warning_from_error_code(self, error_code):
    
    ... ... @@ -192,7 +193,7 @@ class CreateGroupchatWindow(Gtk.ApplicationWindow):
    192 193
         @ensure_not_destroyed
    
    193 194
         def _disco_info_received(self, result):
    
    194 195
             if is_error_result(result):
    
    195
    -            if result.type == 'item-not-found':
    
    196
    +            if result.condition == 'item-not-found':
    
    196 197
                     self._create_muc(result.jid)
    
    197 198
                     return
    
    198 199
                 self._set_warning_from_error(result)
    

  • gajim/gtk/groupchat_join.py
    ... ... @@ -20,6 +20,7 @@ from nbxmpp.util import is_error_result
    20 20
     
    
    21 21
     from gajim.common import app
    
    22 22
     from gajim.common.i18n import _
    
    23
    +from gajim.common.helpers import to_user_string
    
    23 24
     from gajim.common.const import MUC_DISCO_ERRORS
    
    24 25
     
    
    25 26
     from gajim.gtk.groupchat_info import GroupChatInfoScrolled
    
    ... ... @@ -100,7 +101,7 @@ class GroupchatJoin(Gtk.ApplicationWindow):
    100 101
             self._stack.set_visible_child_name('error')
    
    101 102
     
    
    102 103
         def _set_error(self, error):
    
    103
    -        text = MUC_DISCO_ERRORS.get(error.type, str(error))
    
    104
    +        text = MUC_DISCO_ERRORS.get(error.condition, to_user_string(error))
    
    104 105
             self._show_error_page(text)
    
    105 106
     
    
    106 107
         def _set_error_from_code(self, error_code):
    

  • gajim/gtk/pep_config.py
    ... ... @@ -19,6 +19,7 @@ from nbxmpp.util import is_error_result
    19 19
     from gajim.common import app
    
    20 20
     from gajim.common import ged
    
    21 21
     from gajim.common.i18n import _
    
    22
    +from gajim.common.helpers import to_user_string
    
    22 23
     
    
    23 24
     from gajim.gtk.dialogs import ErrorDialog
    
    24 25
     from gajim.gtk.dialogs import WarningDialog
    
    ... ... @@ -88,7 +89,7 @@ class ManagePEPServicesWindow(Gtk.ApplicationWindow):
    88 89
     
    
    89 90
         def _items_received(self, result):
    
    90 91
             if is_error_result(result):
    
    91
    -            ErrorDialog('Error', str(result))
    
    92
    +            ErrorDialog('Error', to_user_string(result))
    
    92 93
                 return
    
    93 94
     
    
    94 95
             jid = result.jid.getBare()
    

  • gajim/gtk/start_chat.py
    ... ... @@ -25,6 +25,7 @@ from nbxmpp.util import is_error_result
    25 25
     from gajim.common import app
    
    26 26
     from gajim.common import helpers
    
    27 27
     from gajim.common.helpers import validate_jid
    
    28
    +from gajim.common.helpers import to_user_string
    
    28 29
     from gajim.common.i18n import _
    
    29 30
     from gajim.common.const import AvatarSize
    
    30 31
     from gajim.common.const import MUC_DISCO_ERRORS
    
    ... ... @@ -291,7 +292,7 @@ class StartChatDialog(Gtk.ApplicationWindow):
    291 292
                 self._set_error_from_code('not-muc-service')
    
    292 293
     
    
    293 294
         def _set_error(self, error):
    
    294
    -        text = MUC_DISCO_ERRORS.get(error.type, str(error))
    
    295
    +        text = MUC_DISCO_ERRORS.get(error.condition, to_user_string(error))
    
    295 296
             self._show_error_page(text)
    
    296 297
     
    
    297 298
         def _set_error_from_code(self, error_code):
    
    ... ... @@ -506,7 +507,7 @@ class StartChatDialog(Gtk.ApplicationWindow):
    506 507
         def _parameters_received(self, result, user_data):
    
    507 508
             if is_error_result(result):
    
    508 509
                 self._global_search_listbox.remove_progress()
    
    509
    -            self._show_error_page(result.message)
    
    510
    +            self._show_error_page(to_user_string(result))
    
    510 511
                 return
    
    511 512
     
    
    512 513
             con, text = user_data
    
    ... ... @@ -521,7 +522,7 @@ class StartChatDialog(Gtk.ApplicationWindow):
    521 522
     
    
    522 523
             if is_error_result(result):
    
    523 524
                 self._global_search_listbox.remove_progress()
    
    524
    -            self._show_error_page(result.message)
    
    525
    +            self._show_error_page(to_user_string(result))
    
    525 526
                 return
    
    526 527
     
    
    527 528
             for item in result.items: