Author: bct
Date: 2008-08-30 03:31:25 +0200 (Sat, 30 Aug 2008)
New Revision: 10354
Modified:
trunk/src/chat_control.py
trunk/src/common/config.py
trunk/src/common/connection.py
trunk/src/common/connection_handlers.py
trunk/src/common/stanza_session.py
Log:
move most of is_loggable out of the session object. fixes #4103
Modified: trunk/src/chat_control.py
===================================================================
--- trunk/src/chat_control.py 2008-08-30 01:31:11 UTC (rev 10353)
+++ trunk/src/chat_control.py 2008-08-30 01:31:25 UTC (rev 10354)
@@ -1530,13 +1530,21 @@
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 @@
'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'''
Modified: trunk/src/common/config.py
===================================================================
--- trunk/src/common/config.py 2008-08-30 01:31:11 UTC (rev 10353)
+++ trunk/src/common/config.py 2008-08-30 01:31:25 UTC (rev 10354)
@@ -642,6 +642,18 @@
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:
Modified: trunk/src/common/connection.py
===================================================================
--- trunk/src/common/connection.py 2008-08-30 01:31:11 UTC (rev 10353)
+++ trunk/src/common/connection.py 2008-08-30 01:31:25 UTC (rev 10354)
@@ -1182,10 +1182,8 @@
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 @@
# 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:
Modified: trunk/src/common/connection_handlers.py
===================================================================
--- trunk/src/common/connection_handlers.py 2008-08-30 01:31:11 UTC (rev 10353)
+++ trunk/src/common/connection_handlers.py 2008-08-30 01:31:25 UTC (rev 10354)
@@ -1841,15 +1841,8 @@
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 @@
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 @@
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 @@
# 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:
Modified: trunk/src/common/stanza_session.py
===================================================================
--- trunk/src/common/stanza_session.py 2008-08-30 01:31:11 UTC (rev 10353)
+++ trunk/src/common/stanza_session.py 2008-08-30 01:31:25 UTC (rev 10354)
@@ -66,16 +66,8 @@
self.negotiated = {}
def is_loggable(self):
- account = self.conn.name
- no_log_for = gajim.config.get_per('accounts', account, 'no_log_for')
+ return self.loggable and gajim.config.should_log(self.conn.name, self.jid)
- 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
# returns True if any events were removed (unlike gajim.events.remove_events)
def remove_events(self, types):