don't print a second DB error message if a first one is already shown. Fixes #5637

This commit is contained in:
Yann Leboulanger 2010-03-09 21:48:57 +01:00
parent 5d6fd195ab
commit 42f1952e15
3 changed files with 23 additions and 9 deletions

View File

@ -430,13 +430,15 @@ class CommonConnection:
try:
gajim.logger.write(kind, jid, log_msg)
except exceptions.PysqliteOperationalError, e:
self.dispatch('ERROR', (_('Disk Write Error'), str(e)))
self.dispatch('DB_ERROR', (_('Disk Write Error'),
str(e)))
except exceptions.DatabaseMalformed:
pritext = _('Database Error')
sectext = _('The database file (%s) cannot be read. Try to '
'repair it (see http://trac.gajim.org/wiki/DatabaseBackup)'
' or remove it (all history will be lost).') % \
common.logger.LOG_DB_PATH
self.dispatch('DB_ERROR', (pritext, sectext))
def ack_subscribed(self, jid):
"""

View File

@ -1566,13 +1566,13 @@ ConnectionCaps, ConnectionHandlersBase, ConnectionJingle):
gajim.logger.write('error', frm, error_msg, tim=tim,
subject=subject)
except exceptions.PysqliteOperationalError, e:
self.dispatch('ERROR', (_('Disk Write Error'), str(e)))
self.dispatch('DB_ERROR', (_('Disk Write Error'), str(e)))
except exceptions.DatabaseMalformed:
pritext = _('Database Error')
sectext = _('The database file (%s) cannot be read. Try to repair '
'it (see http://trac.gajim.org/wiki/DatabaseBackup) or remove '
'it (all history will be lost).') % common.logger.LOG_DB_PATH
self.dispatch('ERROR', (pritext, sectext))
self.dispatch('DB_ERROR', (pritext, sectext))
self.dispatch('MSGERROR', (frm, msg.getErrorCode(), error_msg, msgtxt,
tim, session))
@ -1617,13 +1617,13 @@ ConnectionCaps, ConnectionHandlersBase, ConnectionJingle):
self.last_history_time[jid] = mktime(tim)
except exceptions.PysqliteOperationalError, e:
self.dispatch('ERROR', (_('Disk Write Error'), str(e)))
self.dispatch('DB_ERROR', (_('Disk Write Error'), str(e)))
except exceptions.DatabaseMalformed:
pritext = _('Database Error')
sectext = _('The database file (%s) cannot be read. Try to repair '
'it (see http://trac.gajim.org/wiki/DatabaseBackup) or remove '
'it (all history will be lost).') % common.logger.LOG_DB_PATH
self.dispatch('ERROR', (pritext, sectext))
self.dispatch('DB_ERROR', (pritext, sectext))
def dispatch_invite_message(self, invite, frm):
item = invite.getTag('invite')
@ -1811,14 +1811,15 @@ ConnectionCaps, ConnectionHandlersBase, ConnectionJingle):
try:
gajim.logger.write('gcstatus', who, st, show)
except exceptions.PysqliteOperationalError, e:
self.dispatch('ERROR', (_('Disk Write Error'), str(e)))
self.dispatch('DB_ERROR', (_('Disk Write Error'),
str(e)))
except exceptions.DatabaseMalformed:
pritext = _('Database Error')
sectext = _('The database file (%s) cannot be read. Try to '
'repair it (see http://trac.gajim.org/wiki/DatabaseBackup)'
' or remove it (all history will be lost).') % \
common.logger.LOG_DB_PATH
self.dispatch('ERROR', (pritext, sectext))
self.dispatch('DB_ERROR', (pritext, sectext))
if avatar_sha or avatar_sha == '':
if avatar_sha == '':
# contact has no avatar
@ -1961,14 +1962,14 @@ ConnectionCaps, ConnectionHandlersBase, ConnectionJingle):
try:
gajim.logger.write('status', jid_stripped, status, show)
except exceptions.PysqliteOperationalError, e:
self.dispatch('ERROR', (_('Disk Write Error'), str(e)))
self.dispatch('DB_ERROR', (_('Disk Write Error'), str(e)))
except exceptions.DatabaseMalformed:
pritext = _('Database Error')
sectext = _('The database file (%s) cannot be read. Try to '
'repair it (see http://trac.gajim.org/wiki/DatabaseBackup) '
'or remove it (all history will be lost).') % \
common.logger.LOG_DB_PATH
self.dispatch('ERROR', (pritext, sectext))
self.dispatch('DB_ERROR', (pritext, sectext))
our_jid = gajim.get_jid_from_account(self.name)
if jid_stripped == our_jid and resource == self.server_resource:
# We got our own presence

View File

@ -119,6 +119,15 @@ class Interface:
#('ERROR', account, (title_text, section_text))
dialogs.ErrorDialog(data[0], data[1])
def handle_event_db_error(self, unused, data):
#('DB_ERROR', account, (title_text, section_text))
if self.db_error_dialog:
return
self.db_error_dialog = dialogs.ErrorDialog(data[0], data[1])
def destroyed(win):
self.db_error_dialog = None
self.db_error_dialog.connect('destroy', destroyed)
def handle_event_information(self, unused, data):
#('INFORMATION', account, (title_text, section_text))
dialogs.InformationDialog(data[0], data[1])
@ -2090,6 +2099,7 @@ class Interface:
'ROSTER': [self.handle_event_roster],
'WARNING': [self.handle_event_warning],
'ERROR': [self.handle_event_error],
'DB_ERROR': [self.handle_event_db_error],
'INFORMATION': [self.handle_event_information],
'ERROR_ANSWER': [self.handle_event_error_answer],
'STATUS': [self.handle_event_status],
@ -3281,6 +3291,7 @@ class Interface:
self.status_sent_to_groups = {}
self.gpg_passphrase = {}
self.pass_dialog = {}
self.db_error_dialog = None
self.default_colors = {
'inmsgcolor': gajim.config.get('inmsgcolor'),
'outmsgcolor': gajim.config.get('outmsgcolor'),