From 7216c7b05838f1fa3fc70e14c9dd65b974779951 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Wed, 28 Sep 2011 17:43:59 +0200 Subject: [PATCH] ability to remember for which JID we allow to not store logs. Fixes #6987 --- src/common/config.py | 3 ++- src/session.py | 39 ++++++++++++++++++++++++++++----------- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/src/common/config.py b/src/common/config.py index 4bb7f9b4f..33ef7be85 100644 --- a/src/common/config.py +++ b/src/common/config.py @@ -333,7 +333,8 @@ class Config: 'custom_port': [ opt_int, 5222, '', True ], 'custom_host': [ opt_str, '', '', True ], 'sync_with_global_status': [ opt_bool, False, ], - 'no_log_for': [ opt_str, '' ], + 'no_log_for': [ opt_str, '', _('Space separated list of JIDs for which you do not want to store logs. You can also add account name to log nothing for this account.')], + 'allow_no_log_for': [ opt_str, '', _('Space separated list of JIDs for which you accept to not log conversations if he does not want to.')], 'minimized_gc': [ opt_str, '' ], 'attached_gpg_keys': [ opt_str, '' ], 'keep_alives_enabled': [ opt_bool, True, _('Whitespace sent after inactivity')], diff --git a/src/session.py b/src/session.py index 9f00b53e6..10eb27b9a 100644 --- a/src/session.py +++ b/src/session.py @@ -404,13 +404,11 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession): not_acceptable) self.dialog = dialogs.YesNoDialog(_('Confirm these ' - 'session options'), _('''The remote client wants ' - 'to negotiate an session with these features: - -%s - -Are these options acceptable?''') % (negotiation.describe_features( - ask_user)), + 'session options'), + _('The remote client wants to negotiate a session ' + 'with these features:\n\n%s\n\nAre these options ' + 'acceptable?''') % ( + negotiation.describe_features(ask_user)), on_response_yes=accept_nondefault_options, on_response_no=reject_nondefault_options) else: @@ -434,7 +432,18 @@ Are these options acceptable?''') % (negotiation.describe_features( if ask_user: def accept_nondefault_options(is_checked): - dialog.destroy() + if dialog: + dialog.destroy() + + if is_checked: + allow_no_log_for = gajim.config.get_per( + 'accounts', self.conn.name, + 'allow_no_log_for').split() + jid = str(self.jid) + if jid not in allow_no_log_for: + allow_no_log_for.append(jid) + gajim.config.set_per('accounts', self.conn.name, + 'allow_no_log_for', ' '.join(allow_no_log_for)) negotiated.update(ask_user) @@ -447,10 +456,18 @@ Are these options acceptable?''') % (negotiation.describe_features( self.reject_negotiation() dialog.destroy() - dialog = dialogs.YesNoDialog(_('Confirm these session options'), - _('The remote client selected these options:\n\n%s\n\n' - 'Continue with the session?') % ( + allow_no_log_for = gajim.config.get_per('accounts', + self.conn.name, 'allow_no_log_for').split() + if str(self.jid) in allow_no_log_for: + dialog = None + accept_nondefault_options(False) + else: + dialog = dialogs.YesNoDialog(_('Confirm these session ' + 'options'), + _('The remote client selected these options:\n\n%s' + '\n\nContinue with the session?') % ( negotiation.describe_features(ask_user)), + _('Always accept for this contact'), on_response_yes = accept_nondefault_options, on_response_no = reject_nondefault_options) else: