Fix constants usage in history manager
This commit is contained in:
parent
aaef09fc54
commit
2a599d1e89
|
@ -73,11 +73,7 @@ common.configpaths.gajimpaths.init(config_path)
|
||||||
del config_path
|
del config_path
|
||||||
from common import gajim
|
from common import gajim
|
||||||
import gtkgui_helpers
|
import gtkgui_helpers
|
||||||
from common.logger import LOG_DB_PATH, constants
|
from common.logger import LOG_DB_PATH, JIDConstant, KindConstant
|
||||||
|
|
||||||
#FIXME: constants should implement 2 way mappings
|
|
||||||
status = dict((constants.__dict__[i], i[5:].lower()) for i in \
|
|
||||||
constants.__dict__.keys() if i.startswith('SHOW_'))
|
|
||||||
from common import helpers
|
from common import helpers
|
||||||
import dialogs
|
import dialogs
|
||||||
|
|
||||||
|
@ -324,7 +320,7 @@ class HistoryManager:
|
||||||
possible_room_jid = jid.split('/', 1)[0]
|
possible_room_jid = jid.split('/', 1)[0]
|
||||||
|
|
||||||
self.cur.execute('SELECT jid_id FROM jids WHERE jid = ? AND type = ?',
|
self.cur.execute('SELECT jid_id FROM jids WHERE jid = ? AND type = ?',
|
||||||
(possible_room_jid, constants.JID_ROOM_TYPE))
|
(possible_room_jid, JIDConstant.ROOM_TYPE))
|
||||||
row = self.cur.fetchone()
|
row = self.cur.fetchone()
|
||||||
if row is None:
|
if row is None:
|
||||||
return False
|
return False
|
||||||
|
@ -339,7 +335,7 @@ class HistoryManager:
|
||||||
row = self.cur.fetchone()
|
row = self.cur.fetchone()
|
||||||
if row is None:
|
if row is None:
|
||||||
raise
|
raise
|
||||||
elif row[0] == constants.JID_ROOM_TYPE:
|
elif row[0] == JIDConstant.ROOM_TYPE:
|
||||||
return True
|
return True
|
||||||
else: # normal type
|
else: # normal type
|
||||||
return False
|
return False
|
||||||
|
@ -381,15 +377,15 @@ class HistoryManager:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
color = None
|
color = None
|
||||||
if kind in (constants.KIND_SINGLE_MSG_RECV,
|
if kind in (KindConstant.SINGLE_MSG_RECV,
|
||||||
constants.KIND_CHAT_MSG_RECV, constants.KIND_GC_MSG):
|
KindConstant.CHAT_MSG_RECV, KindConstant.GC_MSG):
|
||||||
# it is the other side
|
# it is the other side
|
||||||
color = gajim.config.get('inmsgcolor') # so incoming color
|
color = gajim.config.get('inmsgcolor') # so incoming color
|
||||||
elif kind in (constants.KIND_SINGLE_MSG_SENT,
|
elif kind in (KindConstant.SINGLE_MSG_SENT,
|
||||||
constants.KIND_CHAT_MSG_SENT): # it is us
|
KindConstant.CHAT_MSG_SENT): # it is us
|
||||||
color = gajim.config.get('outmsgcolor') # so outgoing color
|
color = gajim.config.get('outmsgcolor') # so outgoing color
|
||||||
elif kind in (constants.KIND_STATUS,
|
elif kind in (KindConstant.STATUS,
|
||||||
constants.KIND_GCSTATUS): # is is statuses
|
KindConstant.GCSTATUS): # is is statuses
|
||||||
# so status color
|
# so status color
|
||||||
color = gajim.config.get('statusmsgcolor')
|
color = gajim.config.get('statusmsgcolor')
|
||||||
# include status into (status) message
|
# include status into (status) message
|
||||||
|
@ -522,13 +518,13 @@ class HistoryManager:
|
||||||
# in store: time, kind, message, contact_name FROM logs
|
# in store: time, kind, message, contact_name FROM logs
|
||||||
# in text: JID or You or nickname (if it's gc_msg), time, message
|
# in text: JID or You or nickname (if it's gc_msg), time, message
|
||||||
time_, kind, message, nickname = row
|
time_, kind, message, nickname = row
|
||||||
if kind in (constants.KIND_SINGLE_MSG_RECV,
|
if kind in (KindConstant.SINGLE_MSG_RECV,
|
||||||
constants.KIND_CHAT_MSG_RECV):
|
KindConstant.CHAT_MSG_RECV):
|
||||||
who = self._get_jid_from_jid_id(jid_id)
|
who = self._get_jid_from_jid_id(jid_id)
|
||||||
elif kind in (constants.KIND_SINGLE_MSG_SENT,
|
elif kind in (KindConstant.SINGLE_MSG_SENT,
|
||||||
constants.KIND_CHAT_MSG_SENT):
|
KindConstant.CHAT_MSG_SENT):
|
||||||
who = _('You')
|
who = _('You')
|
||||||
elif kind == constants.KIND_GC_MSG:
|
elif kind == KindConstant.GC_MSG:
|
||||||
who = nickname
|
who = nickname
|
||||||
else: # status or gc_status. do not save
|
else: # status or gc_status. do not save
|
||||||
#print kind
|
#print kind
|
||||||
|
|
Loading…
Reference in New Issue