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