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

Commits:

4 changed files:

Changes:

  • gajim/common/const.py
    ... ... @@ -246,6 +246,7 @@ class MUCJoinedState(Enum):
    246 246
         CREATING = 'creating'
    
    247 247
         CAPTCHA_REQUEST = 'captcha in progress'
    
    248 248
         CAPTCHA_FAILED = 'captcha failed'
    
    249
    +    PASSWORD_REQUEST = 'password request'
    
    249 250
     
    
    250 251
         def __str__(self):
    
    251 252
             return self.name
    
    ... ... @@ -274,6 +275,10 @@ def is_captcha_request(self):
    274 275
         def is_captcha_failed(self):
    
    275 276
             return self == MUCJoinedState.CAPTCHA_FAILED
    
    276 277
     
    
    278
    +    @property
    
    279
    +    def is_password_request(self):
    
    280
    +        return self == MUCJoinedState.PASSWORD_REQUEST
    
    281
    +
    
    277 282
     
    
    278 283
     class ClientState(IntEnum):
    
    279 284
         DISCONNECTING = 0
    

  • gajim/common/modules/muc.py
    ... ... @@ -262,7 +262,8 @@ def join(self,
    262 262
                 # join a different nickname, so update MUCData here.
    
    263 263
                 muc_data.nick = nick
    
    264 264
     
    
    265
    -        if not muc_data.state.is_not_joined:
    
    265
    +        if muc_data.state not in (MUCJoinedState.NOT_JOINED,
    
    266
    +                                  MUCJoinedState.PASSWORD_REQUEST):
    
    266 267
                 self._log.warning('Can’t join MUC %s, state: %s',
    
    267 268
                                   jid, muc_data.state)
    
    268 269
                 return
    
    ... ... @@ -497,8 +498,7 @@ def _on_error_presence(self,
    497 498
     
    
    498 499
                 elif properties.error.condition == 'not-authorized':
    
    499 500
                     self._remove_rejoin_timeout(room_jid)
    
    500
    -                muc_data.error = 'password-request'
    
    501
    -                self._set_muc_state(room_jid, MUCJoinedState.NOT_JOINED)
    
    501
    +                self._set_muc_state(room_jid, MUCJoinedState.PASSWORD_REQUEST)
    
    502 502
                     room.notify('room-password-required', properties)
    
    503 503
     
    
    504 504
                 else:
    
    ... ... @@ -774,6 +774,9 @@ def _fake_subject_change(self, room_jid: str) -> None:
    774 774
             room = self._get_contact(room_jid)
    
    775 775
             room.notify('room-joined')
    
    776 776
     
    
    777
    +    def cancel_password_request(self, room_jid: str) -> None:
    
    778
    +        self._set_muc_state(room_jid, MUCJoinedState.NOT_JOINED)
    
    779
    +
    
    777 780
         def _room_join_complete(self, muc_data: MUCData):
    
    778 781
             self._remove_join_timeout(muc_data.jid)
    
    779 782
             self._set_muc_state(muc_data.jid, MUCJoinedState.JOINED)
    

  • gajim/gtk/chat_function_page.py
    ... ... @@ -156,6 +156,7 @@ def set_mode(self,
    156 156
                 self._confirm_button.get_style_context().add_class(
    
    157 157
                     'suggested-action')
    
    158 158
                 self._widget = InputWidget(self._contact, mode)
    
    159
    +            self._widget.connect('changed', self._on_ready)
    
    159 160
     
    
    160 161
             elif mode == 'captcha-request':
    
    161 162
                 self._confirm_button.set_label(_('Join'))
    
    ... ... @@ -259,14 +260,19 @@ def _on_confirm_clicked(self, _button: Gtk.Button) -> None:
    259 260
             self.emit('finish', False)
    
    260 261
     
    
    261 262
         def _on_cancel_clicked(self, _button: Gtk.Button) -> None:
    
    263
    +        assert self._client is not None
    
    264
    +        assert self._contact is not None
    
    265
    +
    
    262 266
             if self._mode == 'captcha-request':
    
    263
    -            assert self._client is not None
    
    264
    -            assert self._contact is not None
    
    265 267
                 self._client.get_module('MUC').cancel_captcha(
    
    266 268
                     self._contact.jid)
    
    267 269
                 self.emit('finish', True)
    
    268 270
                 return
    
    269 271
     
    
    272
    +        if self._mode == 'password-request':
    
    273
    +            self._client.get_module('MUC').cancel_password_request(
    
    274
    +                self._contact.jid)
    
    275
    +
    
    270 276
             if self._mode in (
    
    271 277
                     'join-failed',
    
    272 278
                     'creation-failed',
    

  • gajim/gtk/chat_stack.py
    ... ... @@ -135,10 +135,11 @@ def show_chat(self, account: str, jid: JID) -> None:
    135 135
                         self._show_chat_function_page('captcha-request')
    
    136 136
                         return
    
    137 137
     
    
    138
    +                if muc_data.state.is_password_request:
    
    139
    +                    self._show_chat_function_page('password-request')
    
    140
    +                    return
    
    141
    +
    
    138 142
                     if not muc_data.state.is_joined:
    
    139
    -                    if muc_data.error == 'password-request':
    
    140
    -                        self._show_chat_function_page('password-request')
    
    141
    -                        return
    
    142 143
                         if muc_data.error == 'captcha-failed':
    
    143 144
                             self._show_chat_function_page(
    
    144 145
                                 'captcha-error', muc_data.error_text)