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


Commits:
c327dbfe by lovetox at 2022-08-12T23:48:21+02:00
refactor: ChatControl: Remove dead encryption code

- - - - -
d9ac569c by lovetox at 2022-08-13T00:03:04+02:00
imprv: ChatControl: Show error if encryption plugin is missing

- - - - -


3 changed files:

- gajim/gtk/chat_stack.py
- gajim/gtk/control.py
- gajim/gui_interface.py


Changes:

=====================================
gajim/gtk/chat_stack.py
=====================================
@@ -41,6 +41,7 @@
 from gajim.common.modules.contacts import GroupchatParticipant
 from gajim.common.structs import OutgoingMessage
 from gajim.common.types import ChatContactT
+from gajim.gui.dialogs import ErrorDialog
 
 from .chat_banner import ChatBanner
 from .chat_function_page import ChatFunctionPage
@@ -664,6 +665,11 @@ def _on_send_message(self) -> None:
 
         encryption = contact.settings.get('encryption')
         if encryption:
+            if encryption not in app.plugin_manager.encryption_plugins:
+                ErrorDialog(_('Encryption error'),
+                            _('Missing necessary encryption plugin'))
+                return
+
             self._chat_control.sendmessage = True
             app.plugin_manager.extension_point(
                 'send_message' + encryption,


=====================================
gajim/gtk/control.py
=====================================
@@ -99,8 +99,6 @@ def __init__(self) -> None:
         # XEP-0333 Chat Markers
         self.last_msg_id: Optional[str] = None
 
-        self.encryption: Optional[str] = None
-
         self._subject_text_cache: dict[JID, str] = {}
 
         self.widget = cast(Gtk.Box, self._ui.get_object('control_box'))
@@ -147,7 +145,6 @@ def clear(self) -> None:
 
         self._contact = None
         self._client = None
-        self.encryption = None
         self.last_msg_id = None
         self.reset_view()
         self._scrolled_view.clear()
@@ -172,8 +169,6 @@ def switch_contact(self, contact: Union[BareContact,
         self._groupchat_state.switch_contact(contact)
         self._roster.switch_contact(contact)
 
-        self.encryption = self.get_encryption_state()
-
         self._register_events()
 
         if isinstance(contact, GroupchatParticipant):
@@ -453,19 +448,6 @@ def mark_as_read(self, send_marker: bool = True) -> None:
                 self.last_msg_id)
             self.last_msg_id = None
 
-    def set_encryption_state(self, encryption: Optional[str]) -> None:
-        self.encryption = encryption
-        self.contact.settings.set('encryption', self.encryption or '')
-
-    def get_encryption_state(self) -> Optional[str]:
-        state = self.contact.settings.get('encryption')
-        if not state:
-            return None
-        if state not in app.plugin_manager.encryption_plugins:
-            self.set_encryption_state(None)
-            return None
-        return state
-
     def _on_autoscroll_changed(self,
                                _widget: ScrolledView,
                                autoscroll: bool


=====================================
gajim/gui_interface.py
=====================================
@@ -326,10 +326,11 @@ def _on_file_dialog_ok(self,
 
     def _send_httpupload(self, chat_control: ChatControl, path: str) -> None:
         client = app.get_client(chat_control.contact.account)
+        encryption = chat_control.contact.settings.get('encryption') or None
         try:
             transfer = client.get_module('HTTPUpload').make_transfer(
                 path,
-                chat_control.encryption,
+                encryption,
                 chat_control.contact,
                 chat_control.is_groupchat)
         except exceptions.FileError as error:



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/compare/2ac83815d02a8f1a458c259807e8a6b9cf67c60a...d9ac569c221dca9ef8272837a516a10dffda504f

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/compare/2ac83815d02a8f1a458c259807e8a6b9cf67c60a...d9ac569c221dca9ef8272837a516a10dffda504f
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list
Commits@gajim.org
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to