It is now possible to not log history for each user

This commit is contained in:
Yann Leboulanger 2004-11-15 09:51:30 +00:00
parent 896e193cbc
commit 17f66ed851
4 changed files with 77 additions and 8 deletions

View File

@ -374,7 +374,7 @@ class GajimCore:
def presenceCB(self, con, prs):
"""Called when we recieve a presence"""
if prs.getXNode(common.jabber.NS_DELAY): return
# if prs.getXNode(common.jabber.NS_DELAY): return
who = str(prs.getFrom())
prio = prs.getPriority()
if not prio:
@ -657,7 +657,6 @@ class GajimCore:
if ev[2][0] != ev[2][2]:
self.hub.sendPlugin('CONFIG', None, (ev[2][0], ev[2][1]))
self.cfgParser.writeCfgFile()
#TODO: tell the changes to other plugins
#('STATUS', account, (status, msg))
elif ev[0] == 'STATUS':
msg = ev[2][1]

View File

@ -22,6 +22,7 @@ pygtk.require('2.0')
import gtk
from gtk import TRUE, FALSE
import gtk.glade,gobject
import string
from common import i18n
_ = i18n._
APP = i18n.APP
@ -77,6 +78,24 @@ class infoUser_Window:
if update:
self.plugin.send('UPDUSER', self.account, (self.user.jid, \
self.user.name, self.user.groups))
#log history ?
acct = self.plugin.accounts[self.account]
oldlog = 1
no_log_for = []
if acct.has_key('no_log_for'):
no_log_for = acct['no_log_for'].split(' ')
if self.user.jid in no_log_for:
oldlog = 0
log = self.xml.get_widget('chk_log').get_active()
if not log and not self.user.jid in no_log_for:
no_log_for.append(self.user.jid)
if log and self.user.jid in no_log_for:
no_log_for.remove(self.user.jid)
if oldlog != log:
acct['no_log_for'] = string.join(no_log_for, ' ')
self.plugin.accounts[self.account] = acct
self.plugin.send('CONFIG', None, ('accounts', self.plugin.accounts, \
'Gtkgui'))
widget.get_toplevel().destroy()
def add_grp(self, model, path, iter, stors):
@ -162,6 +181,12 @@ class infoUser_Window:
self.xml.get_widget('label_id').set_text(user.jid)
self.xml.get_widget('label_sub').set_text(user.sub)
self.xml.get_widget('entry_name').set_text(user.name)
acct = self.plugin.accounts[account]
log = 1
if acct.has_key('no_log_for'):
if user.jid in acct['no_log_for'].split(' '):
log = 0
self.xml.get_widget('chk_log').set_active(log)
resources = user.resource + ' (' + str(user.priority) + ')'
if not user.status:
user.status = ''

View File

@ -5205,7 +5205,7 @@ when NOT online</property>
<widget class="GtkTable" id="table4">
<property name="border_width">4</property>
<property name="visible">True</property>
<property name="n_rows">5</property>
<property name="n_rows">6</property>
<property name="n_columns">2</property>
<property name="homogeneous">False</property>
<property name="row_spacing">0</property>
@ -5447,6 +5447,29 @@ when NOT online</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="chk_log">
<property name="border_width">5</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Log history</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">True</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">2</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
</widget>
<packing>
<property name="tab_expand">False</property>

View File

@ -77,8 +77,10 @@ class plugin:
print _("plugin logger stopped")
return
elif ev[0] == 'NOTIFY':
status = ev[2][2]
jid = string.split(ev[2][0], '/')[0]
if jid in self.no_log_for[ev[1]]:
break
status = ev[2][2]
if not status:
status = ""
status = string.replace(status, '\n', '\\n')
@ -93,15 +95,19 @@ class plugin:
ev[2][1], status))
fic.close()
elif ev[0] == 'MSG':
msg = string.replace(ev[2][1], '\n', '\\n')
jid = string.split(ev[2][0], '/')[0]
if jid in self.no_log_for[ev[1]]:
break
msg = string.replace(ev[2][1], '\n', '\\n')
fic = open(LOGPATH + jid, "a")
t = time.mktime(ev[2][2])
fic.write("%s:recv:%s\n" % (t, msg))
fic.close()
elif ev[0] == 'MSGSENT':
msg = string.replace(ev[2][1], '\n', '\\n')
jid = string.split(ev[2][0], '/')[0]
if jid in self.no_log_for[ev[1]]:
break
msg = string.replace(ev[2][1], '\n', '\\n')
fic = open(LOGPATH + jid, "a")
fic.write("%s:sent:%s\n" % (tim, msg))
fic.close()
@ -119,6 +125,14 @@ class plugin:
elif ev[0] == 'CONFIG':
if ev[2][0] == 'Logger':
self.config = ev[2][1]
if ev[2][0] == 'accounts':
accounts = ev[2][1]
self.no_log_for = {}
for acct in accounts.keys():
self.no_log_for[acct] = []
if accounts[acct].has_key('no_log_for'):
self.no_log_for[acct] = \
string.split(accounts[acct]['no_log_for'], ' ')
time.sleep(0.1)
def wait(self, what):
@ -139,6 +153,14 @@ class plugin:
quOUT.put(('ASK_CONFIG', None, ('Logger', 'Logger', {\
'lognotsep':1, 'lognotusr':1})))
self.config = self.wait('CONFIG')
quOUT.put(('ASK_CONFIG', None, ('Logger', 'accounts')))
accounts = self.wait('CONFIG')
self.no_log_for = {}
for acct in accounts.keys():
self.no_log_for[acct] = []
if accounts[acct].has_key('no_log_for'):
self.no_log_for[acct] = \
string.split(accounts[acct]['no_log_for'], ' ')
#create ~/.gajim/logs/ if it doesn't exist
try:
os.stat(os.path.expanduser("~/.gajim"))