Philipp Hörist pushed to branch gajim_1.2 at gajim / gajim
Commits: 73030407 by lovetox at 2020-07-05T11:00:33+02:00 MamPreferences: Correctly display preference state for JID
- - - - - f8c68062 by lovetox at 2020-07-05T11:00:33+02:00 Interface: Store password with correct backend
On account creation use the passwords module to store the password correctly
- - - - - 644b4374 by lovetox at 2020-07-05T11:00:33+02:00 Remove comment
- - - - - ad0ef193 by lovetox at 2020-07-05T11:00:33+02:00 CertStore: Add cert to cache on add_certificate()
Otherwise the cert is only available after a restart
Fixes #10160
- - - - - 221345f9 by lovetox at 2020-07-05T11:00:33+02:00 Determine correctly if block/unblock menuitem is shown
- - - - - 1e53583e by André Apitzsch at 2020-07-05T11:00:33+02:00 MusicTrackListener: Catch all errors
Fixes #10164.
- - - - - 0deda0f8 by Daniel Brötzmann at 2020-07-05T11:00:33+02:00 Preferences: Fix tooltip string for auto copy
- - - - - 32db5e3b by Daniel Brötzmann at 2020-07-05T11:00:33+02:00 MessageWindow: Fix deprecated properties, don’t expand label
- - - - - 25252179 by Daniel Brötzmann at 2020-07-05T11:00:33+02:00 SubscriptionRequest: Add block/report features
- - - - - 037b0aba by lovetox at 2020-07-05T11:00:33+02:00 Rename methods/vars
SSL -> TLS
- - - - - 12b81860 by lovetox at 2020-07-05T11:00:33+02:00 Remove unused code
Its impossible to get connected by accident without TLS. Connecting unencrypted is now a feature for developers. So showing a icon that reflects transport encryption seems not useful anymore.
We still show TLS information in the Server Info window
- - - - -
15 changed files:
- gajim/common/app.py - gajim/common/cert_store.py - gajim/common/client.py - gajim/common/dbus/music_track.py - gajim/common/helpers.py - gajim/data/gui/message_window.ui - gajim/data/gui/preferences_window.ui - gajim/data/gui/subscription_request_window.ui - gajim/gtk/mam_preferences.py - gajim/gtk/ssl_error_dialog.py - gajim/gtk/subscription_request.py - gajim/gtk/tooltips.py - gajim/gui_interface.py - gajim/gui_menu_builder.py - gajim/roster_window.py
Changes:
===================================== gajim/common/app.py ===================================== @@ -115,9 +115,6 @@ nicks = {} # type: Dict[str, str] # from this transport block_signed_in_notifications = {} # type: Dict[str, bool]
- # type of each connection (ssl, tls, tcp, ...) -con_types = {} # type: Dict[str, Optional[str]] - proxy65_manager = None
cert_store = None @@ -466,21 +463,6 @@ def in_groupchat(account, room_jid): return False return gc_connected[account][room_jid]
-def get_number_of_securely_connected_accounts(): - """ - Return the number of the accounts that are SSL/TLS connected - """ - num_of_secured = 0 - for account in connections: - if account_is_securely_connected(account): - num_of_secured += 1 - return num_of_secured - -def account_is_securely_connected(account): - if not account_is_connected(account): - return False - return con_types.get(account) in ('tls', 'ssl') - def get_transport_name_from_jid(jid, use_config_setting=True): """ Returns 'gg', 'irc' etc
===================================== gajim/common/cert_store.py ===================================== @@ -62,6 +62,7 @@ class CertificateStore:
def add_certificate(self, certificate): log.info('Add certificate to trust store') + self._certs.append(certificate) pem = certificate.props.certificate_pem path = self._get_random_path() write_file_async(path,
===================================== gajim/common/client.py ===================================== @@ -33,7 +33,7 @@ from gajim.common.helpers import get_custom_host from gajim.common.helpers import get_user_proxy from gajim.common.helpers import warn_about_plain_connection from gajim.common.helpers import get_resource -from gajim.common.helpers import get_ignored_ssl_errors +from gajim.common.helpers import get_ignored_tls_errors from gajim.common.helpers import get_idle_status_message from gajim.common.idle import Monitor from gajim.common.i18n import _ @@ -79,7 +79,7 @@ class Client(ConnectionHandlers): self._destroy_client = False self._remove_account = False
- self._ssl_errors = set() + self._tls_errors = set()
self._destroyed = False
@@ -178,7 +178,7 @@ class Client(ConnectionHandlers): app.cert_store.get_certificates())
self._client.set_ignored_tls_errors( - get_ignored_ssl_errors(self._account)) + get_ignored_tls_errors(self._account))
if app.config.get_per('accounts', self._account, 'use_plain_connection'): @@ -200,8 +200,8 @@ class Client(ConnectionHandlers): for handler in modules.get_handlers(self): self._client.register_handler(handler)
- def process_ssl_errors(self): - if not self._ssl_errors: + def process_tls_errors(self): + if not self._tls_errors: self.connect(ignore_all_errors=True) return
@@ -209,7 +209,7 @@ class Client(ConnectionHandlers): account=self._account, connection=self, cert=self._client.peer_certificate[0], - error_num=self._ssl_errors.pop()) + error_num=self._tls_errors.pop())
def _on_resume_failed(self, _client, _signal_name): log.info('Resume failed') @@ -261,13 +261,13 @@ class Client(ConnectionHandlers): self._reconnect = False
elif domain == StreamError.BAD_CERTIFICATE: - self._ssl_errors = self._client.peer_certificate[1] + self._tls_errors = self._client.peer_certificate[1] self.get_module('Chatstate').enabled = False self._reconnect = False self._after_disconnect() app.nec.push_incoming_event(NetworkEvent( 'our-show', account=self._account, show='offline')) - self.process_ssl_errors() + self.process_tls_errors()
elif domain in (StreamError.STREAM, StreamError.BIND): if error == 'conflict':
===================================== gajim/common/dbus/music_track.py ===================================== @@ -85,10 +85,8 @@ class MusicTrackListener: -1, None) except GLib.Error as error: - if error.domain == 'g-dbus-error-quark': - log.debug("Could not list names: %s", error.message) - return - raise + log.debug("Could not list names: %s", error.message) + return
for name in result[0]: if name.startswith(MPRIS_PLAYER_PREFIX): @@ -199,12 +197,10 @@ class MusicTrackListener: -1, None) except GLib.Error as error: - if error.domain == 'g-dbus-error-quark': - log.debug("Could not enable music listener: %s", error.message) - return None - raise - else: - return self._get_music_info(result[0]) + log.debug("Could not enable music listener: %s", error.message) + return None + + return self._get_music_info(result[0])
def enable():
===================================== gajim/common/helpers.py ===================================== @@ -1545,7 +1545,7 @@ def warn_about_plain_connection(account, connection_types): return False
-def get_ignored_ssl_errors(account): +def get_ignored_tls_errors(account): ignore_ssl_errors = app.config.get_per( 'accounts', account, 'ignore_ssl_errors').split() return {Gio.TlsCertificateFlags(int(err)) for err in ignore_ssl_errors}
===================================== gajim/data/gui/message_window.ui ===================================== @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.22.1 --> +<!-- Generated with glade 3.36.0 --> <interface> - <requires lib="gtk+" version="3.12"/> + <requires lib="gtk+" version="3.22"/> <object class="GtkEventBox" id="chat_tab_ebox"> <property name="visible">True</property> <property name="can_focus">False</property> @@ -17,7 +17,6 @@ <property name="visible">True</property> <property name="can_focus">False</property> <property name="halign">start</property> - <property name="stock">gtk-missing-image</property> </object> <packing> <property name="expand">False</property> @@ -30,8 +29,7 @@ <property name="visible">True</property> <property name="can_focus">False</property> <property name="halign">start</property> - <property name="margin_left">3</property> - <property name="hexpand">True</property> + <property name="margin_start">3</property> <property name="use_markup">True</property> <property name="ellipsize">end</property> <property name="single_line_mode">True</property> @@ -48,17 +46,16 @@ </child> <child> <object class="GtkButton" id="tab_close_button"> - <property name="use_action_appearance">False</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> <property name="halign">end</property> <property name="relief">none</property> <child> - <object class="GtkImage" id="image1329"> + <object class="GtkImage"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="stock">gtk-close</property> + <property name="icon_name">window-close</property> <property name="icon_size">1</property> </object> </child> @@ -78,9 +75,6 @@ <property name="default_width">480</property> <property name="default_height">440</property> <property name="show_menubar">False</property> - <child type="titlebar"> - <placeholder/> - </child> <child> <object class="GtkNotebook" id="notebook"> <property name="visible">True</property> @@ -88,5 +82,8 @@ <property name="scrollable">True</property> </object> </child> + <child type="titlebar"> + <placeholder/> + </child> </object> </interface>
===================================== gajim/data/gui/preferences_window.ui ===================================== @@ -585,7 +585,7 @@ <property name="label" translatable="yes">Enable auto copy</property> <property name="can_focus">True</property> <property name="receives_default">False</property> - <property name="tooltip_text" translatable="yes">If enabled, selecting Text will be copied to the clipboard, otherwise you can copy text with CTRL + SHIFT + C</property> + <property name="tooltip_text" translatable="yes">If enabled, selected text will automatically be copied to the clipboard, otherwise you can copy text with CTRL + SHIFT + C</property> <property name="halign">start</property> <property name="use_underline">True</property> <property name="draw_indicator">True</property>
===================================== gajim/data/gui/subscription_request_window.ui ===================================== @@ -1,7 +1,67 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.22.1 --> +<!-- Generated with glade 3.36.0 --> <interface> <requires lib="gtk+" version="3.20"/> + <object class="GtkPopoverMenu" id="deny_popover"> + <property name="can_focus">False</property> + <child> + <object class="GtkBox"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="border_width">6</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> + <child> + <object class="GtkModelButton" id="deny_button"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="text" translatable="yes">_Deny</property> + <signal name="clicked" handler="_on_deny_clicked" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkModelButton" id="block_button"> + <property name="visible">True</property> + <property name="sensitive">False</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="text" translatable="yes">_Block User</property> + <signal name="clicked" handler="_on_block_clicked" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkModelButton" id="report_button"> + <property name="visible">True</property> + <property name="sensitive">False</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="text" translatable="yes">_Report as Spam</property> + <signal name="clicked" handler="_on_report_clicked" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> + </object> + <packing> + <property name="submenu">main</property> + <property name="position">1</property> + </packing> + </child> + </object> <object class="GtkImage" id="image1"> <property name="visible">True</property> <property name="can_focus">False</property> @@ -26,22 +86,20 @@ <property name="row_spacing">6</property> <property name="column_spacing">12</property> <child> - <object class="GtkLabel" id="jid_label"> + <object class="GtkLabel"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="halign">start</property> - <property name="label"><XMPP address></property> + <property name="label">Subscription Request</property> <property name="wrap">True</property> <property name="wrap_mode">word-char</property> - <property name="max_width_chars">50</property> - <property name="xalign">0</property> <style> <class name="large-header"/> </style> </object> <packing> - <property name="left_attach">1</property> + <property name="left_attach">0</property> <property name="top_attach">0</property> + <property name="width">2</property> </packing> </child> <child> @@ -84,38 +142,35 @@ </packing> </child> <child> - <object class="GtkButton" id="contact_info_button"> + <object class="GtkButton" id="start_chat_button"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="tooltip_text" translatable="yes">Contact Information</property> + <property name="receives_default">False</property> + <property name="tooltip_text" translatable="yes">Start Chat</property> <property name="valign">center</property> - <property name="image">image2</property> - <signal name="clicked" handler="_on_contact_info_clicked" swapped="no"/> + <property name="image">image1</property> + <signal name="clicked" handler="_on_start_chat_clicked" swapped="no"/> </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">0</property> + <property name="top_attach">2</property> </packing> </child> <child> - <object class="GtkButton" id="start_chat_button"> + <object class="GtkButton" id="contact_info_button"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="tooltip_text" translatable="yes">Start Chat</property> + <property name="receives_default">False</property> + <property name="tooltip_text" translatable="yes">Contact Information</property> <property name="valign">center</property> - <property name="image">image1</property> - <signal name="clicked" handler="_on_start_chat_clicked" swapped="no"/> + <property name="image">image2</property> + <signal name="clicked" handler="_on_contact_info_clicked" swapped="no"/> </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">2</property> + <property name="top_attach">1</property> </packing> </child> - <child> - <placeholder/> - </child> </object> <packing> <property name="expand">False</property> @@ -144,15 +199,20 @@ <property name="spacing">12</property> <property name="homogeneous">True</property> <child> - <object class="GtkButton" id="deny_button"> - <property name="label" translatable="yes">_Deny</property> + <object class="GtkMenuButton"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="can_default">True</property> - <property name="receives_default">False</property> - <property name="tooltip_text" translatable="yes">Deny authorization from contact so the contact cannot know if you are connected</property> - <property name="use_underline">True</property> - <signal name="clicked" handler="_on_deny_clicked" swapped="no"/> + <property name="focus_on_click">False</property> + <property name="receives_default">True</property> + <property name="popover">deny_popover</property> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">_Deny…</property> + <property name="use_underline">True</property> + </object> + </child> </object> <packing> <property name="expand">False</property> @@ -166,9 +226,8 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="can_default">True</property> - <property name="has_default">True</property> - <property name="receives_default">False</property> - <property name="tooltip_text" translatable="yes">Authorize contact so the contact can know if you are connected</property> + <property name="receives_default">True</property> + <property name="tooltip_text" translatable="yes">Allows the contact to see your online status</property> <property name="use_underline">True</property> <signal name="clicked" handler="_on_authorize_clicked" swapped="no"/> <style> @@ -178,7 +237,7 @@ <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="position">1</property> + <property name="position">2</property> </packing> </child> </object>
===================================== gajim/gtk/mam_preferences.py ===================================== @@ -78,10 +78,10 @@ class MamPreferences(Gtk.ApplicationWindow, EventHelper): self._ui.default_combo.set_active_id(result.default) self._ui.preferences_store.clear() for jid in result.always: - self._ui.preferences_store.append((str(jid), 'Always')) + self._ui.preferences_store.append((str(jid), True))
for jid in result.never: - self._ui.preferences_store.append((str(jid), 'Never')) + self._ui.preferences_store.append((str(jid), False))
@ensure_not_destroyed def _mam_prefs_saved(self, result): @@ -137,8 +137,8 @@ class MamPreferences(Gtk.ApplicationWindow, EventHelper): never = [] default = self._ui.default_combo.get_active_id() for item in self._ui.preferences_store: - jid, type_ = item - if type_ == 'Always': + jid, archive = item + if archive: always.append(jid) else: never.append(jid)
===================================== gajim/gtk/ssl_error_dialog.py ===================================== @@ -80,4 +80,4 @@ class SSLErrorDialog(Gtk.ApplicationWindow): app.cert_store.add_certificate(self._cert)
self.destroy() - self._con.process_ssl_errors() + self._con.process_tls_errors()
===================================== gajim/gtk/subscription_request.py ===================================== @@ -13,6 +13,7 @@ # along with Gajim. If not, see http://www.gnu.org/licenses/.
from gi.repository import Gtk +from gi.repository import Gdk
from gajim import vcard
@@ -33,25 +34,38 @@ class SubscriptionRequest(Gtk.ApplicationWindow): self.set_position(Gtk.WindowPosition.CENTER) self.set_title(_('Subscription Request'))
- self._ui = get_builder('subscription_request_window.ui') - self.add(self._ui.subscription_box) self.jid = jid self.account = account self.user_nick = user_nick - self._ui.jid_label.set_text(self.jid) + + self._ui = get_builder('subscription_request_window.ui') + self.add(self._ui.subscription_box) + self._ui.authorize_button.grab_default() + if len(app.connections) >= 2: - prompt_text = \ - _('Subscription request for account %(account)s from %(jid)s')\ - % {'account': account, 'jid': self.jid} + prompt_text = _( + 'Subscription request for account %(account)s from ' + '%(jid)s') % {'account': self.account, 'jid': self.jid} else: prompt_text = _('Subscription request from %s') % self.jid
self._ui.request_label.set_text(prompt_text) self._ui.subscription_text.set_text(text)
+ con = app.connections[self.account] + if con.get_module('Blocking').supported: + self._ui.block_button.set_sensitive(True) + self._ui.report_button.set_sensitive(True) + + self.connect('key-press-event', self._on_key_press) + self._ui.connect_signals(self) self.show_all()
+ def _on_key_press(self, _widget, event): + if event.keyval == Gdk.KEY_Escape: + self.destroy() + def _on_authorize_clicked(self, _widget): """ Accept the request @@ -86,12 +100,28 @@ class SubscriptionRequest(Gtk.ApplicationWindow): app.interface.new_chat_from_jid(self.account, self.jid)
def _on_deny_clicked(self, _widget): - """ - Refuse the request - """ + self._deny_request() + self._remove_contact() + + def _on_block_clicked(self, _widget): + self._deny_request() + con = app.connections[self.account] + con.get_module('Blocking').block([self.jid]) + self._remove_contact() + + def _on_report_clicked(self, _widget): + self._deny_request() + con = app.connections[self.account] + con.get_module('Blocking').block([self.jid], report='spam') + self._remove_contact() + + def _deny_request(self): con = app.connections[self.account] con.get_module('Presence').unsubscribed(self.jid) + + def _remove_contact(self): contact = app.contacts.get_contact(self.account, self.jid) if contact and _('Not in contact list') in contact.get_shown_groups(): - app.interface.roster.remove_contact(self.jid, self.account) + app.interface.roster.remove_contact( + self.jid, self.account, force=True, backend=True) self.destroy()
===================================== gajim/gtk/tooltips.py ===================================== @@ -91,8 +91,7 @@ class StatusTable: 1) self.current_row += 1
- def add_status_row(self, show, str_status, show_lock=False, - indent=True, transport=None): + def add_status_row(self, show, str_status, indent=True, transport=None): """ Append a new row with status icon to the table """ @@ -117,10 +116,6 @@ class StatusTable: status_label.set_ellipsize(Pango.EllipsizeMode.END) status_label.set_max_width_chars(30) self.table.attach(status_label, 3, self.current_row, 1, 1) - if show_lock: - lock_image = Gtk.Image() - lock_image.set_from_icon_name('dialog-password', Gtk.IconSize.MENU) - self.table.attach(lock_image, 4, self.current_row, 1, 1) self.current_row += 1
def fill_table_with_accounts(self, accounts): @@ -128,8 +123,6 @@ class StatusTable: message = acct['message'] message = helpers.reduce_chars_newlines(message, 100, 1) message = GLib.markup_escape_text(message) - con_type = app.con_types.get(acct['name']) - show_lock = con_type in ('tls', 'ssl')
account_label = GLib.markup_escape_text(acct['account_label']) if message: @@ -137,10 +130,7 @@ class StatusTable: else: status = account_label
- self.add_status_row(acct['show'], - status, - show_lock=show_lock, - indent=False) + self.add_status_row(acct['show'], status, indent=False)
for line in acct['event_lines']: self.add_text_row(' ' + line, 1)
===================================== gajim/gui_interface.py ===================================== @@ -1521,7 +1521,6 @@ class Interface: '%s@%s' % (username, domain)) config['hostname'] = domain config['savepass'] = True - config['password'] = password config['anonymous_auth'] = anonymous config['autoconnect'] = True config['sync_with_global_status'] = True @@ -1542,10 +1541,14 @@ class Interface: for opt in config: app.config.set_per('accounts', account, opt, config[opt])
+ # Password module depends on existing config + passwords.save_password(account, password) + app.css_config.refresh() - # refresh accounts window + # Action must be added before account window is updated app.app.add_account_actions(account) + window = get_app_window('AccountsWindow') if window is not None: window.add_account(account)
===================================== gajim/gui_menu_builder.py ===================================== @@ -397,7 +397,7 @@ control=None, gc_contact=None, is_anonymous=True): if helpers.jid_is_blocked(account, jid): block_menuitem.set_no_show_all(True) block_menuitem.hide() - if transport != 'jabber': + if transport not in ('jabber', None): unblock_menuitem.set_no_show_all(True) unblock_menuitem.hide() unignore_menuitem.set_no_show_all(False) @@ -409,7 +409,7 @@ control=None, gc_contact=None, is_anonymous=True): else: unblock_menuitem.set_no_show_all(True) unblock_menuitem.hide() - if transport != 'jabber': + if transport not in ('jabber', None): block_menuitem.set_no_show_all(True) block_menuitem.hide() ignore_menuitem.set_no_show_all(False)
===================================== gajim/roster_window.py ===================================== @@ -290,13 +290,9 @@ class RosterWindow: show = helpers.get_connection_status(account) our_jid = app.get_jid_from_account(account)
- tls_pixbuf = None - if app.account_is_securely_connected(account): - tls_pixbuf = 'changes-prevent' - it = self.model.append(None, [get_icon_name(show), GLib.markup_escape_text(account), 'account', our_jid, - account, None, None, None, None, None, tls_pixbuf, True] + + account, None, None, None, None, None, None, True] + [None] * self.nb_ext_renderers) self._iters[account]['account'] = it
@@ -1009,15 +1005,6 @@ class RosterWindow: if not child_iter: return
- num_of_accounts = app.get_number_of_connected_accounts() - num_of_secured = app.get_number_of_securely_connected_accounts() - - tls_pixbuf = None - if app.account_is_securely_connected(account) and not self.regroup or\ - self.regroup and num_of_secured and num_of_secured == num_of_accounts: - tls_pixbuf = 'changes-prevent' - self.model[child_iter][Column.PADLOCK_PIXBUF] = tls_pixbuf - if self.regroup: account_name = _('Merged accounts') accounts = [] @@ -2188,8 +2175,6 @@ class RosterWindow: # No need to redraw contacts if we're quitting if child_iterA: self.model[child_iterA][Column.AVATAR_IMG] = None - if account in app.con_types: - app.con_types[account] = None for jid in list(app.contacts.get_jid_list(account)): lcontact = app.contacts.get_contacts(account, jid) ctrl = app.interface.msg_win_mgr.get_gc_control(jid,
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/compare/85c1c83559353229de2462a9ad0af792...