move most of is_loggable out of the session object. fixes #4103
This commit is contained in:
parent
29c6af7e1e
commit
32b56a2328
|
@ -1530,13 +1530,21 @@ class ChatControl(ChatControlBase):
|
|||
ChatControlBase.print_conversation_line(self, msg,
|
||||
'status', '', None)
|
||||
|
||||
loggable = gajim.config.get('log_encrypted_sessions')
|
||||
|
||||
if self.session:
|
||||
self.session.loggable = gajim.config.get(
|
||||
'log_encrypted_sessions');
|
||||
if self.session and not self.session.is_loggable():
|
||||
msg = _('Session WILL NOT be logged')
|
||||
self.session.loggable = loggable
|
||||
|
||||
loggable = self.session.is_loggable()
|
||||
else:
|
||||
loggable = loggable and gajim.config.should_log(self.account,
|
||||
self.contact.jid)
|
||||
|
||||
if loggable:
|
||||
msg = _('Session WILL be logged')
|
||||
else:
|
||||
msg = _('Session WILL NOT be logged')
|
||||
|
||||
ChatControlBase.print_conversation_line(self, msg,
|
||||
'status', '', None)
|
||||
|
||||
|
@ -1548,8 +1556,7 @@ class ChatControl(ChatControlBase):
|
|||
'gpg_enabled', self.gpg_is_active)
|
||||
|
||||
self._show_lock_image(self.gpg_is_active, 'GPG',
|
||||
self.gpg_is_active,
|
||||
self.session and self.session.is_loggable(), True)
|
||||
self.gpg_is_active, loggable, True)
|
||||
|
||||
def _show_lock_image(self, visible, enc_type = '', enc_enabled = False, chat_logged = False, authenticated = False):
|
||||
'''Set lock icon visibility and create tooltip'''
|
||||
|
|
|
@ -642,6 +642,18 @@ class Config:
|
|||
return obj[subname][OPT_RESTART]
|
||||
return False
|
||||
|
||||
def should_log(self, account, jid):
|
||||
'''should conversations between a local account and a remote jid be
|
||||
logged?'''
|
||||
no_log_for = self.get_per('accounts', account, 'no_log_for')
|
||||
|
||||
if not no_log_for:
|
||||
no_log_for = ''
|
||||
|
||||
no_log_for = no_log_for.split()
|
||||
|
||||
return (account not in no_log_for) and (jid not in no_log_for)
|
||||
|
||||
def __init__(self):
|
||||
#init default values
|
||||
for event in self.soundevents_default:
|
||||
|
|
|
@ -1182,10 +1182,8 @@ class Connection(ConnectionHandlers):
|
|||
|
||||
msg_id = self.connection.send(msg_iq)
|
||||
if not forward_from and session and session.is_loggable():
|
||||
no_log_for = gajim.config.get_per('accounts', self.name, 'no_log_for')\
|
||||
.split()
|
||||
ji = gajim.get_jid_without_resource(jid)
|
||||
if self.name not in no_log_for and ji not in no_log_for:
|
||||
if gajim.config.should_log(self.name, ji):
|
||||
log_msg = msg
|
||||
if original_message != None:
|
||||
log_msg = original_message
|
||||
|
@ -1515,11 +1513,9 @@ class Connection(ConnectionHandlers):
|
|||
# last date/time in history to avoid duplicate
|
||||
if not self.last_history_time.has_key(room_jid):
|
||||
# Not in memory, get it from DB
|
||||
no_log_for = gajim.config.get_per('accounts', self.name, 'no_log_for')\
|
||||
.split()
|
||||
last_log = None
|
||||
# Do not check if we are not logging for this room
|
||||
if self.name not in no_log_for and room_jid not in no_log_for:
|
||||
if gajim.config.should_log(self.name, room_jid):
|
||||
# Check time first in the FAST table
|
||||
last_log = gajim.logger.get_room_last_message_time(room_jid)
|
||||
if last_log is None:
|
||||
|
|
|
@ -1841,15 +1841,8 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
|
|||
self.dispatch('GC_MSG', (frm, msgtxt, tim, has_timestamp, msg.getXHTML(),
|
||||
statusCode))
|
||||
|
||||
no_log_for = gajim.config.get_per('accounts', self.name, 'no_log_for')
|
||||
|
||||
if not no_log_for:
|
||||
no_log_for = ''
|
||||
|
||||
no_log_for = no_log_for.split()
|
||||
tim_int = int(float(mktime(tim)))
|
||||
|
||||
if self.name not in no_log_for and jid not in no_log_for and not \
|
||||
if gajim.config.should_log(self.name, jid) and not \
|
||||
tim_int <= self.last_history_time[jid] and msgtxt and frm.find('/') >= 0:
|
||||
# if frm.find('/') < 0, it means message comes from room itself
|
||||
# usually it hold description and can be send at each connection
|
||||
|
@ -1963,8 +1956,6 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
|
|||
if self.connection.getRoster().getItem(agent): # to be sure it's a transport contact
|
||||
transport_auto_auth = True
|
||||
|
||||
no_log_for = gajim.config.get_per('accounts', self.name,
|
||||
'no_log_for').split()
|
||||
status = prs.getStatus() or ''
|
||||
show = prs.getShow()
|
||||
if not show in STATUS_LIST:
|
||||
|
@ -2020,8 +2011,8 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
|
|||
self.dispatch('ERROR_ANSWER', ('', jid_stripped,
|
||||
errmsg, errcode))
|
||||
if not ptype or ptype == 'unavailable':
|
||||
if gajim.config.get('log_contact_status_changes') and self.name\
|
||||
not in no_log_for and jid_stripped not in no_log_for:
|
||||
if gajim.config.get('log_contact_status_changes') and \
|
||||
gajim.config.should_log(self.name, jid_stripped):
|
||||
gc_c = gajim.contacts.get_gc_contact(self.name, jid_stripped,
|
||||
resource)
|
||||
st = status or ''
|
||||
|
@ -2149,8 +2140,8 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
|
|||
# avatar has been updated
|
||||
self.request_vcard(jid_stripped)
|
||||
if not ptype or ptype == 'unavailable':
|
||||
if gajim.config.get('log_contact_status_changes') and self.name \
|
||||
not in no_log_for and jid_stripped not in no_log_for:
|
||||
if gajim.config.get('log_contact_status_changes') and \
|
||||
gajim.config.should_log(self.name, jid_stripped):
|
||||
try:
|
||||
gajim.logger.write('status', jid_stripped, status, show)
|
||||
except exceptions.PysqliteOperationalError, e:
|
||||
|
|
|
@ -66,15 +66,7 @@ class StanzaSession(object):
|
|||
self.negotiated = {}
|
||||
|
||||
def is_loggable(self):
|
||||
account = self.conn.name
|
||||
no_log_for = gajim.config.get_per('accounts', account, 'no_log_for')
|
||||
|
||||
if not no_log_for:
|
||||
no_log_for = ''
|
||||
|
||||
no_log_for = no_log_for.split()
|
||||
|
||||
return self.loggable and account not in no_log_for and self.jid not in no_log_for
|
||||
return self.loggable and gajim.config.should_log(self.conn.name, self.jid)
|
||||
|
||||
# remove events associated with this session from the queue
|
||||
# returns True if any events were removed (unlike gajim.events.remove_events)
|
||||
|
|
Loading…
Reference in New Issue