It is now possible to not log history for each user
This commit is contained in:
parent
896e193cbc
commit
17f66ed851
|
@ -374,7 +374,7 @@ class GajimCore:
|
||||||
|
|
||||||
def presenceCB(self, con, prs):
|
def presenceCB(self, con, prs):
|
||||||
"""Called when we recieve a presence"""
|
"""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())
|
who = str(prs.getFrom())
|
||||||
prio = prs.getPriority()
|
prio = prs.getPriority()
|
||||||
if not prio:
|
if not prio:
|
||||||
|
@ -654,10 +654,9 @@ class GajimCore:
|
||||||
self.gpg[a] = MyGnuPG()
|
self.gpg[a] = MyGnuPG()
|
||||||
else:
|
else:
|
||||||
self.cfgParser.tab[ev[2][0]] = ev[2][1]
|
self.cfgParser.tab[ev[2][0]] = ev[2][1]
|
||||||
if ev[2][0] != ev[2][2]:
|
if ev[2][0] != ev[2][2]:
|
||||||
self.hub.sendPlugin('CONFIG', None, (ev[2][0], ev[2][1]))
|
self.hub.sendPlugin('CONFIG', None, (ev[2][0], ev[2][1]))
|
||||||
self.cfgParser.writeCfgFile()
|
self.cfgParser.writeCfgFile()
|
||||||
#TODO: tell the changes to other plugins
|
|
||||||
#('STATUS', account, (status, msg))
|
#('STATUS', account, (status, msg))
|
||||||
elif ev[0] == 'STATUS':
|
elif ev[0] == 'STATUS':
|
||||||
msg = ev[2][1]
|
msg = ev[2][1]
|
||||||
|
|
|
@ -22,6 +22,7 @@ pygtk.require('2.0')
|
||||||
import gtk
|
import gtk
|
||||||
from gtk import TRUE, FALSE
|
from gtk import TRUE, FALSE
|
||||||
import gtk.glade,gobject
|
import gtk.glade,gobject
|
||||||
|
import string
|
||||||
from common import i18n
|
from common import i18n
|
||||||
_ = i18n._
|
_ = i18n._
|
||||||
APP = i18n.APP
|
APP = i18n.APP
|
||||||
|
@ -77,6 +78,24 @@ class infoUser_Window:
|
||||||
if update:
|
if update:
|
||||||
self.plugin.send('UPDUSER', self.account, (self.user.jid, \
|
self.plugin.send('UPDUSER', self.account, (self.user.jid, \
|
||||||
self.user.name, self.user.groups))
|
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()
|
widget.get_toplevel().destroy()
|
||||||
|
|
||||||
def add_grp(self, model, path, iter, stors):
|
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_id').set_text(user.jid)
|
||||||
self.xml.get_widget('label_sub').set_text(user.sub)
|
self.xml.get_widget('label_sub').set_text(user.sub)
|
||||||
self.xml.get_widget('entry_name').set_text(user.name)
|
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) + ')'
|
resources = user.resource + ' (' + str(user.priority) + ')'
|
||||||
if not user.status:
|
if not user.status:
|
||||||
user.status = ''
|
user.status = ''
|
||||||
|
|
|
@ -5205,7 +5205,7 @@ when NOT online</property>
|
||||||
<widget class="GtkTable" id="table4">
|
<widget class="GtkTable" id="table4">
|
||||||
<property name="border_width">4</property>
|
<property name="border_width">4</property>
|
||||||
<property name="visible">True</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="n_columns">2</property>
|
||||||
<property name="homogeneous">False</property>
|
<property name="homogeneous">False</property>
|
||||||
<property name="row_spacing">0</property>
|
<property name="row_spacing">0</property>
|
||||||
|
@ -5447,6 +5447,29 @@ when NOT online</property>
|
||||||
<property name="y_options"></property>
|
<property name="y_options"></property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</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>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="tab_expand">False</property>
|
<property name="tab_expand">False</property>
|
||||||
|
|
|
@ -77,8 +77,10 @@ class plugin:
|
||||||
print _("plugin logger stopped")
|
print _("plugin logger stopped")
|
||||||
return
|
return
|
||||||
elif ev[0] == 'NOTIFY':
|
elif ev[0] == 'NOTIFY':
|
||||||
status = ev[2][2]
|
|
||||||
jid = string.split(ev[2][0], '/')[0]
|
jid = string.split(ev[2][0], '/')[0]
|
||||||
|
if jid in self.no_log_for[ev[1]]:
|
||||||
|
break
|
||||||
|
status = ev[2][2]
|
||||||
if not status:
|
if not status:
|
||||||
status = ""
|
status = ""
|
||||||
status = string.replace(status, '\n', '\\n')
|
status = string.replace(status, '\n', '\\n')
|
||||||
|
@ -93,15 +95,19 @@ class plugin:
|
||||||
ev[2][1], status))
|
ev[2][1], status))
|
||||||
fic.close()
|
fic.close()
|
||||||
elif ev[0] == 'MSG':
|
elif ev[0] == 'MSG':
|
||||||
msg = string.replace(ev[2][1], '\n', '\\n')
|
|
||||||
jid = string.split(ev[2][0], '/')[0]
|
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 = open(LOGPATH + jid, "a")
|
||||||
t = time.mktime(ev[2][2])
|
t = time.mktime(ev[2][2])
|
||||||
fic.write("%s:recv:%s\n" % (t, msg))
|
fic.write("%s:recv:%s\n" % (t, msg))
|
||||||
fic.close()
|
fic.close()
|
||||||
elif ev[0] == 'MSGSENT':
|
elif ev[0] == 'MSGSENT':
|
||||||
msg = string.replace(ev[2][1], '\n', '\\n')
|
|
||||||
jid = string.split(ev[2][0], '/')[0]
|
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 = open(LOGPATH + jid, "a")
|
||||||
fic.write("%s:sent:%s\n" % (tim, msg))
|
fic.write("%s:sent:%s\n" % (tim, msg))
|
||||||
fic.close()
|
fic.close()
|
||||||
|
@ -119,6 +125,14 @@ class plugin:
|
||||||
elif ev[0] == 'CONFIG':
|
elif ev[0] == 'CONFIG':
|
||||||
if ev[2][0] == 'Logger':
|
if ev[2][0] == 'Logger':
|
||||||
self.config = ev[2][1]
|
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)
|
time.sleep(0.1)
|
||||||
|
|
||||||
def wait(self, what):
|
def wait(self, what):
|
||||||
|
@ -139,6 +153,14 @@ class plugin:
|
||||||
quOUT.put(('ASK_CONFIG', None, ('Logger', 'Logger', {\
|
quOUT.put(('ASK_CONFIG', None, ('Logger', 'Logger', {\
|
||||||
'lognotsep':1, 'lognotusr':1})))
|
'lognotsep':1, 'lognotusr':1})))
|
||||||
self.config = self.wait('CONFIG')
|
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
|
#create ~/.gajim/logs/ if it doesn't exist
|
||||||
try:
|
try:
|
||||||
os.stat(os.path.expanduser("~/.gajim"))
|
os.stat(os.path.expanduser("~/.gajim"))
|
||||||
|
|
Loading…
Reference in New Issue