Philipp Hörist pushed to branch master at gajim / gajim
Commits:
3 changed files:
Changes:
| ... | ... | @@ -41,6 +41,7 @@ |
| 41 | 41 | from gajim.common.modules.contacts import GroupchatParticipant
|
| 42 | 42 | from gajim.common.structs import OutgoingMessage
|
| 43 | 43 | from gajim.common.types import ChatContactT
|
| 44 | +from gajim.gui.dialogs import ErrorDialog
|
|
| 44 | 45 | |
| 45 | 46 | from .chat_banner import ChatBanner
|
| 46 | 47 | from .chat_function_page import ChatFunctionPage
|
| ... | ... | @@ -664,6 +665,11 @@ def _on_send_message(self) -> None: |
| 664 | 665 | |
| 665 | 666 | encryption = contact.settings.get('encryption')
|
| 666 | 667 | if encryption:
|
| 668 | + if encryption not in app.plugin_manager.encryption_plugins:
|
|
| 669 | + ErrorDialog(_('Encryption error'),
|
|
| 670 | + _('Missing necessary encryption plugin'))
|
|
| 671 | + return
|
|
| 672 | + |
|
| 667 | 673 | self._chat_control.sendmessage = True
|
| 668 | 674 | app.plugin_manager.extension_point(
|
| 669 | 675 | 'send_message' + encryption,
|
| ... | ... | @@ -99,8 +99,6 @@ def __init__(self) -> None: |
| 99 | 99 | # XEP-0333 Chat Markers
|
| 100 | 100 | self.last_msg_id: Optional[str] = None
|
| 101 | 101 | |
| 102 | - self.encryption: Optional[str] = None
|
|
| 103 | - |
|
| 104 | 102 | self._subject_text_cache: dict[JID, str] = {}
|
| 105 | 103 | |
| 106 | 104 | self.widget = cast(Gtk.Box, self._ui.get_object('control_box'))
|
| ... | ... | @@ -147,7 +145,6 @@ def clear(self) -> None: |
| 147 | 145 | |
| 148 | 146 | self._contact = None
|
| 149 | 147 | self._client = None
|
| 150 | - self.encryption = None
|
|
| 151 | 148 | self.last_msg_id = None
|
| 152 | 149 | self.reset_view()
|
| 153 | 150 | self._scrolled_view.clear()
|
| ... | ... | @@ -172,8 +169,6 @@ def switch_contact(self, contact: Union[BareContact, |
| 172 | 169 | self._groupchat_state.switch_contact(contact)
|
| 173 | 170 | self._roster.switch_contact(contact)
|
| 174 | 171 | |
| 175 | - self.encryption = self.get_encryption_state()
|
|
| 176 | - |
|
| 177 | 172 | self._register_events()
|
| 178 | 173 | |
| 179 | 174 | if isinstance(contact, GroupchatParticipant):
|
| ... | ... | @@ -453,19 +448,6 @@ def mark_as_read(self, send_marker: bool = True) -> None: |
| 453 | 448 | self.last_msg_id)
|
| 454 | 449 | self.last_msg_id = None
|
| 455 | 450 | |
| 456 | - def set_encryption_state(self, encryption: Optional[str]) -> None:
|
|
| 457 | - self.encryption = encryption
|
|
| 458 | - self.contact.settings.set('encryption', self.encryption or '')
|
|
| 459 | - |
|
| 460 | - def get_encryption_state(self) -> Optional[str]:
|
|
| 461 | - state = self.contact.settings.get('encryption')
|
|
| 462 | - if not state:
|
|
| 463 | - return None
|
|
| 464 | - if state not in app.plugin_manager.encryption_plugins:
|
|
| 465 | - self.set_encryption_state(None)
|
|
| 466 | - return None
|
|
| 467 | - return state
|
|
| 468 | - |
|
| 469 | 451 | def _on_autoscroll_changed(self,
|
| 470 | 452 | _widget: ScrolledView,
|
| 471 | 453 | autoscroll: bool
|
| ... | ... | @@ -326,10 +326,11 @@ def _on_file_dialog_ok(self, |
| 326 | 326 | |
| 327 | 327 | def _send_httpupload(self, chat_control: ChatControl, path: str) -> None:
|
| 328 | 328 | client = app.get_client(chat_control.contact.account)
|
| 329 | + encryption = chat_control.contact.settings.get('encryption') or None
|
|
| 329 | 330 | try:
|
| 330 | 331 | transfer = client.get_module('HTTPUpload').make_transfer(
|
| 331 | 332 | path,
|
| 332 | - chat_control.encryption,
|
|
| 333 | + encryption,
|
|
| 333 | 334 | chat_control.contact,
|
| 334 | 335 | chat_control.is_groupchat)
|
| 335 | 336 | except exceptions.FileError as error:
|