2003-10-22 20:45:13 +02:00
|
|
|
##
|
2007-10-22 13:33:50 +02:00
|
|
|
## Copyright (C) 2005-2006 Yann Leboulanger <asterix@lagaule.org>
|
2006-10-12 00:45:33 +02:00
|
|
|
## Copyright (C) 2005-2006 Nikos Kouremenos <kourem@gmail.com>
|
2007-09-01 01:19:23 +02:00
|
|
|
## Copyright (C) 2007 Stephan Erb <steve-e@h3c.de>
|
2003-10-22 20:45:13 +02:00
|
|
|
##
|
2007-10-22 13:13:13 +02:00
|
|
|
## This file is part of Gajim.
|
|
|
|
##
|
|
|
|
## Gajim is free software; you can redistribute it and/or modify
|
2003-10-22 20:45:13 +02:00
|
|
|
## it under the terms of the GNU General Public License as published
|
2007-10-22 13:13:13 +02:00
|
|
|
## by the Free Software Foundation; version 3 only.
|
2003-10-22 20:45:13 +02:00
|
|
|
##
|
2007-10-22 13:13:13 +02:00
|
|
|
## Gajim is distributed in the hope that it will be useful,
|
2003-10-22 20:45:13 +02:00
|
|
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
## GNU General Public License for more details.
|
|
|
|
##
|
2007-10-22 13:13:13 +02:00
|
|
|
## You should have received a copy of the GNU General Public License
|
|
|
|
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
##
|
2003-10-22 20:45:13 +02:00
|
|
|
|
2005-04-16 19:03:21 +02:00
|
|
|
import os
|
2005-08-28 12:45:29 +02:00
|
|
|
import locale
|
2005-04-16 19:03:21 +02:00
|
|
|
from common import gajim
|
2003-10-22 20:45:13 +02:00
|
|
|
|
2006-10-12 00:45:33 +02:00
|
|
|
import exceptions
|
|
|
|
try:
|
|
|
|
import sqlite3 as sqlite # python 2.5
|
|
|
|
except ImportError:
|
|
|
|
try:
|
|
|
|
from pysqlite2 import dbapi2 as sqlite
|
|
|
|
except ImportError:
|
|
|
|
raise exceptions.PysqliteNotAvailable
|
|
|
|
import logger
|
|
|
|
|
2005-01-22 21:26:43 +01:00
|
|
|
class OptionsParser:
|
2005-04-27 01:45:25 +02:00
|
|
|
def __init__(self, filename):
|
2005-05-20 20:08:24 +02:00
|
|
|
self.__filename = filename
|
2006-10-12 00:45:33 +02:00
|
|
|
self.old_values = {} # values that are saved in the file and maybe
|
|
|
|
# no longer valid
|
2003-10-22 20:45:13 +02:00
|
|
|
|
2005-04-27 01:45:25 +02:00
|
|
|
def read_line(self, line):
|
2005-05-06 10:33:23 +02:00
|
|
|
index = line.find(' = ')
|
2005-04-27 01:45:25 +02:00
|
|
|
var_str = line[0:index]
|
|
|
|
value_str = line[index + 3:-1]
|
|
|
|
|
|
|
|
i_start = var_str.find('.')
|
|
|
|
i_end = var_str.rfind('.')
|
|
|
|
|
|
|
|
if i_start == -1:
|
2005-11-14 10:43:27 +01:00
|
|
|
self.old_values[var_str] = value_str
|
2005-04-27 01:45:25 +02:00
|
|
|
gajim.config.set(var_str, value_str)
|
|
|
|
else:
|
|
|
|
optname = var_str[0:i_start]
|
|
|
|
key = var_str[i_start + 1:i_end]
|
|
|
|
subname = var_str[i_end + 1:]
|
|
|
|
gajim.config.add_per(optname, key)
|
|
|
|
gajim.config.set_per(optname, key, subname, value_str)
|
|
|
|
|
|
|
|
def read(self):
|
2003-10-22 20:45:13 +02:00
|
|
|
try:
|
2005-04-27 01:45:25 +02:00
|
|
|
fd = open(self.__filename)
|
2003-10-22 20:45:13 +02:00
|
|
|
except:
|
2005-05-06 10:33:23 +02:00
|
|
|
if os.path.exists(self.__filename):
|
2005-08-24 14:38:41 +02:00
|
|
|
#we talk about a file
|
2005-08-23 11:17:48 +02:00
|
|
|
print _('error: cannot open %s for reading') % self.__filename
|
2007-11-17 16:03:02 +01:00
|
|
|
return False
|
2003-10-22 20:45:13 +02:00
|
|
|
|
2005-11-14 10:43:27 +01:00
|
|
|
new_version = gajim.config.get('version')
|
2007-09-27 23:34:00 +02:00
|
|
|
new_version = new_version.split('-', 1)[0]
|
2005-04-27 01:45:25 +02:00
|
|
|
for line in fd.readlines():
|
2005-08-28 12:45:29 +02:00
|
|
|
try:
|
|
|
|
line = line.decode('utf-8')
|
|
|
|
except UnicodeDecodeError:
|
|
|
|
line = line.decode(locale.getpreferredencoding())
|
2005-04-27 01:45:25 +02:00
|
|
|
self.read_line(line)
|
2005-11-14 10:43:27 +01:00
|
|
|
old_version = gajim.config.get('version')
|
2007-09-27 23:34:00 +02:00
|
|
|
old_version = old_version.split('-', 1)[0]
|
2005-11-14 10:43:27 +01:00
|
|
|
|
|
|
|
self.update_config(old_version, new_version)
|
|
|
|
self.old_values = {} # clean mem
|
2005-04-16 19:03:21 +02:00
|
|
|
|
2005-04-27 01:45:25 +02:00
|
|
|
fd.close()
|
2007-11-17 16:03:02 +01:00
|
|
|
return True
|
2005-04-16 19:03:21 +02:00
|
|
|
|
2005-04-27 01:45:25 +02:00
|
|
|
def write_line(self, fd, opt, parents, value):
|
2008-04-18 02:02:56 +02:00
|
|
|
if value is None:
|
2005-08-26 02:52:44 +02:00
|
|
|
return
|
|
|
|
value = value[1]
|
2005-08-26 14:34:11 +02:00
|
|
|
# convert to utf8 before writing to file if needed
|
|
|
|
if isinstance(value, unicode):
|
2005-08-26 02:52:44 +02:00
|
|
|
value = value.encode('utf-8')
|
|
|
|
else:
|
|
|
|
value = str(value)
|
2005-08-26 14:34:11 +02:00
|
|
|
if isinstance(opt, unicode):
|
2005-08-26 02:52:44 +02:00
|
|
|
opt = opt.encode('utf-8')
|
2005-05-06 10:33:23 +02:00
|
|
|
s = ''
|
2005-04-27 01:45:25 +02:00
|
|
|
if parents:
|
|
|
|
if len(parents) == 1:
|
|
|
|
return
|
|
|
|
for p in parents:
|
2005-08-26 14:34:11 +02:00
|
|
|
if isinstance(p, unicode):
|
2005-08-26 02:52:44 +02:00
|
|
|
p = p.encode('utf-8')
|
2005-05-06 10:33:23 +02:00
|
|
|
s += p + '.'
|
2005-04-27 01:45:25 +02:00
|
|
|
s += opt
|
2005-08-26 02:52:44 +02:00
|
|
|
fd.write(s + ' = ' + value + '\n')
|
2005-04-27 01:45:25 +02:00
|
|
|
|
|
|
|
def write(self):
|
2005-08-01 11:37:41 +02:00
|
|
|
(base_dir, filename) = os.path.split(self.__filename)
|
2005-08-13 13:17:49 +02:00
|
|
|
self.__tempfile = os.path.join(base_dir, '.' + filename)
|
2003-10-22 20:45:13 +02:00
|
|
|
try:
|
2005-11-22 11:56:25 +01:00
|
|
|
f = open(self.__tempfile, 'w')
|
|
|
|
except IOError, e:
|
|
|
|
return str(e)
|
2005-08-01 11:37:41 +02:00
|
|
|
try:
|
2005-11-22 15:12:34 +01:00
|
|
|
gajim.config.foreach(self.write_line, f)
|
2005-08-01 11:37:41 +02:00
|
|
|
except IOError, e:
|
2005-11-22 11:56:25 +01:00
|
|
|
return str(e)
|
|
|
|
f.close()
|
2005-08-02 22:33:44 +02:00
|
|
|
if os.path.exists(self.__filename):
|
2005-08-03 00:29:25 +02:00
|
|
|
# win32 needs this
|
2005-08-02 22:33:44 +02:00
|
|
|
try:
|
|
|
|
os.remove(self.__filename)
|
|
|
|
except:
|
|
|
|
pass
|
2005-08-01 11:37:41 +02:00
|
|
|
try:
|
|
|
|
os.rename(self.__tempfile, self.__filename)
|
2005-08-09 13:17:32 +02:00
|
|
|
except IOError, e:
|
2005-11-22 11:56:25 +01:00
|
|
|
return str(e)
|
2005-08-23 11:30:54 +02:00
|
|
|
os.chmod(self.__filename, 0600)
|
2005-11-14 10:43:27 +01:00
|
|
|
|
|
|
|
def update_config(self, old_version, new_version):
|
2006-10-07 12:19:25 +02:00
|
|
|
old_version_list = old_version.split('.') # convert '0.x.y' to (0, x, y)
|
2006-01-11 13:18:32 +01:00
|
|
|
old = []
|
2006-06-05 12:52:35 +02:00
|
|
|
while len(old_version_list):
|
|
|
|
old.append(int(old_version_list.pop(0)))
|
|
|
|
new_version_list = new_version.split('.')
|
2006-01-11 13:18:32 +01:00
|
|
|
new = []
|
2006-06-05 12:52:35 +02:00
|
|
|
while len(new_version_list):
|
|
|
|
new.append(int(new_version_list.pop(0)))
|
2006-01-11 13:18:32 +01:00
|
|
|
|
2006-03-26 12:24:42 +02:00
|
|
|
if old < [0, 9] and new >= [0, 9]:
|
2005-11-14 10:43:27 +01:00
|
|
|
self.update_config_x_to_09()
|
2006-03-26 12:24:42 +02:00
|
|
|
if old < [0, 10] and new >= [0, 10]:
|
2006-01-11 13:18:32 +01:00
|
|
|
self.update_config_09_to_010()
|
2006-06-02 13:21:05 +02:00
|
|
|
if old < [0, 10, 1, 1] and new >= [0, 10, 1, 1]:
|
|
|
|
self.update_config_to_01011()
|
2006-06-10 20:18:46 +02:00
|
|
|
if old < [0, 10, 1, 2] and new >= [0, 10, 1, 2]:
|
|
|
|
self.update_config_to_01012()
|
2006-07-30 00:29:59 +02:00
|
|
|
if old < [0, 10, 1, 3] and new >= [0, 10, 1, 3]:
|
|
|
|
self.update_config_to_01013()
|
2006-10-07 12:19:25 +02:00
|
|
|
if old < [0, 10, 1, 4] and new >= [0, 10, 1, 4]:
|
|
|
|
self.update_config_to_01014()
|
2006-10-08 11:57:23 +02:00
|
|
|
if old < [0, 10, 1, 5] and new >= [0, 10, 1, 5]:
|
|
|
|
self.update_config_to_01015()
|
2006-10-12 03:28:09 +02:00
|
|
|
if old < [0, 10, 1, 6] and new >= [0, 10, 1, 6]:
|
|
|
|
self.update_config_to_01016()
|
2006-11-03 20:52:39 +01:00
|
|
|
if old < [0, 10, 1, 7] and new >= [0, 10, 1, 7]:
|
|
|
|
self.update_config_to_01017()
|
2006-11-26 10:06:47 +01:00
|
|
|
if old < [0, 10, 1, 8] and new >= [0, 10, 1, 8]:
|
|
|
|
self.update_config_to_01018()
|
2007-01-12 20:27:00 +01:00
|
|
|
if old < [0, 11, 0, 1] and new >= [0, 11, 0, 1]:
|
2007-01-13 20:28:42 +01:00
|
|
|
self.update_config_to_01101()
|
2007-01-28 20:16:38 +01:00
|
|
|
if old < [0, 11, 0, 2] and new >= [0, 11, 0, 2]:
|
|
|
|
self.update_config_to_01102()
|
2007-06-26 13:37:01 +02:00
|
|
|
if old < [0, 11, 1, 1] and new >= [0, 11, 1, 1]:
|
|
|
|
self.update_config_to_01111()
|
2007-07-04 18:50:54 +02:00
|
|
|
if old < [0, 11, 1, 2] and new >= [0, 11, 1, 2]:
|
|
|
|
self.update_config_to_01112()
|
2007-07-09 23:24:47 +02:00
|
|
|
if old < [0, 11, 1, 3] and new >= [0, 11, 1, 3]:
|
|
|
|
self.update_config_to_01113()
|
2007-07-11 12:09:31 +02:00
|
|
|
if old < [0, 11, 1, 4] and new >= [0, 11, 1, 4]:
|
|
|
|
self.update_config_to_01114()
|
2007-07-13 16:44:01 +02:00
|
|
|
if old < [0, 11, 1, 5] and new >= [0, 11, 1, 5]:
|
|
|
|
self.update_config_to_01115()
|
2007-09-29 22:51:38 +02:00
|
|
|
if old < [0, 11, 2, 1] and new >= [0, 11, 2, 1]:
|
|
|
|
self.update_config_to_01121()
|
2007-12-26 22:30:45 +01:00
|
|
|
if old < [0, 11, 4, 1] and new >= [0, 11, 4, 1]:
|
|
|
|
self.update_config_to_01141()
|
2008-01-27 21:15:17 +01:00
|
|
|
if old < [0, 11, 4, 2] and new >= [0, 11, 4, 2]:
|
|
|
|
self.update_config_to_01142()
|
2008-04-15 03:52:11 +02:00
|
|
|
if old < [0, 11, 4, 3] and new >= [0, 11, 4, 3]:
|
|
|
|
self.update_config_to_01143()
|
2008-04-21 00:58:47 +02:00
|
|
|
if old < [0, 11, 4, 4] and new >= [0, 11, 4, 4]:
|
|
|
|
self.update_config_to_01144()
|
2006-10-07 12:19:25 +02:00
|
|
|
|
2006-07-31 09:45:29 +02:00
|
|
|
gajim.logger.init_vars()
|
2006-06-05 12:52:35 +02:00
|
|
|
gajim.config.set('version', new_version)
|
2007-07-09 23:24:47 +02:00
|
|
|
|
|
|
|
gajim.capscache.load_from_db()
|
2005-11-14 10:43:27 +01:00
|
|
|
|
|
|
|
def update_config_x_to_09(self):
|
|
|
|
# Var name that changed:
|
|
|
|
# avatar_width /height -> chat_avatar_width / height
|
|
|
|
if self.old_values.has_key('avatar_width'):
|
|
|
|
gajim.config.set('chat_avatar_width', self.old_values['avatar_width'])
|
|
|
|
if self.old_values.has_key('avatar_height'):
|
|
|
|
gajim.config.set('chat_avatar_height', self.old_values['avatar_height'])
|
2005-11-19 23:03:58 +01:00
|
|
|
if self.old_values.has_key('use_dbus'):
|
|
|
|
gajim.config.set('remote_control', self.old_values['use_dbus'])
|
2005-11-14 10:43:27 +01:00
|
|
|
# always_compact_view -> always_compact_view_chat / _gc
|
|
|
|
if self.old_values.has_key('always_compact_view'):
|
|
|
|
gajim.config.set('always_compact_view_chat',
|
|
|
|
self.old_values['always_compact_view'])
|
|
|
|
gajim.config.set('always_compact_view_gc',
|
|
|
|
self.old_values['always_compact_view'])
|
|
|
|
# new theme: grocery, plain
|
|
|
|
d = ['accounttextcolor', 'accountbgcolor', 'accountfont',
|
|
|
|
'accountfontattrs', 'grouptextcolor', 'groupbgcolor', 'groupfont',
|
|
|
|
'groupfontattrs', 'contacttextcolor', 'contactbgcolor', 'contactfont',
|
2006-03-01 12:03:56 +01:00
|
|
|
'contactfontattrs', 'bannertextcolor', 'bannerbgcolor', 'bannerfont',
|
|
|
|
'bannerfontattrs']
|
2007-07-04 18:50:54 +02:00
|
|
|
for theme_name in (_('grocery'), _('default')):
|
2005-11-14 10:43:27 +01:00
|
|
|
if theme_name not in gajim.config.get_per('themes'):
|
|
|
|
gajim.config.add_per('themes', theme_name)
|
|
|
|
theme = gajim.config.themes_default[theme_name]
|
|
|
|
for o in d:
|
|
|
|
gajim.config.set_per('themes', theme_name, o, theme[d.index(o)])
|
2005-11-14 15:19:53 +01:00
|
|
|
# Remove cyan theme if it's not the current theme
|
2005-11-28 23:12:46 +01:00
|
|
|
if 'cyan' in gajim.config.get_per('themes'):
|
2005-11-14 10:43:27 +01:00
|
|
|
gajim.config.del_per('themes', 'cyan')
|
2005-11-28 23:12:46 +01:00
|
|
|
if _('cyan') in gajim.config.get_per('themes'):
|
|
|
|
gajim.config.del_per('themes', _('cyan'))
|
|
|
|
# If we removed our roster_theme, choose the default green one or another
|
|
|
|
# one if doesn't exists in config
|
|
|
|
if gajim.config.get('roster_theme') not in gajim.config.get_per('themes'):
|
|
|
|
theme = _('green')
|
|
|
|
if theme not in gajim.config.get_per('themes'):
|
|
|
|
theme = gajim.config.get_per('themes')[0]
|
|
|
|
gajim.config.set('roster_theme', theme)
|
2005-11-14 10:43:27 +01:00
|
|
|
# new proxies in accounts.name.file_transfer_proxies
|
|
|
|
for account in gajim.config.get_per('accounts'):
|
|
|
|
proxies = gajim.config.get_per('accounts', account,
|
|
|
|
'file_transfer_proxies')
|
2006-03-25 21:29:29 +01:00
|
|
|
if proxies.find('proxy.netlab.cz') < 0:
|
|
|
|
proxies += ', ' + 'proxy.netlab.cz'
|
2005-11-14 15:19:53 +01:00
|
|
|
gajim.config.set_per('accounts', account, 'file_transfer_proxies',
|
2005-11-14 10:43:27 +01:00
|
|
|
proxies)
|
2006-04-10 13:46:53 +02:00
|
|
|
|
2005-11-14 10:43:27 +01:00
|
|
|
gajim.config.set('version', '0.9')
|
2006-01-11 13:18:32 +01:00
|
|
|
|
2006-04-12 10:38:51 +02:00
|
|
|
def assert_unread_msgs_table_exists(self):
|
|
|
|
'''create table unread_messages if there is no such table'''
|
2007-01-02 18:56:26 +01:00
|
|
|
back = os.getcwd()
|
|
|
|
os.chdir(logger.LOG_DB_FOLDER)
|
|
|
|
con = sqlite.connect(logger.LOG_DB_FILE)
|
|
|
|
os.chdir(back)
|
2006-04-12 10:38:51 +02:00
|
|
|
cur = con.cursor()
|
|
|
|
try:
|
|
|
|
cur.executescript(
|
|
|
|
'''
|
|
|
|
CREATE TABLE unread_messages (
|
|
|
|
message_id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
|
|
|
|
jid_id INTEGER
|
|
|
|
);
|
|
|
|
'''
|
|
|
|
)
|
|
|
|
con.commit()
|
2006-04-12 12:08:59 +02:00
|
|
|
gajim.logger.init_vars()
|
2006-04-12 10:38:51 +02:00
|
|
|
except sqlite.OperationalError, e:
|
|
|
|
pass
|
|
|
|
con.close()
|
|
|
|
|
2006-01-11 13:18:32 +01:00
|
|
|
def update_config_09_to_010(self):
|
2006-01-20 14:54:02 +01:00
|
|
|
if self.old_values.has_key('usetabbedchat') and not \
|
2006-04-10 14:09:05 +02:00
|
|
|
self.old_values['usetabbedchat']:
|
2006-01-11 13:18:32 +01:00
|
|
|
gajim.config.set('one_message_window', 'never')
|
2006-01-20 14:54:02 +01:00
|
|
|
if self.old_values.has_key('autodetect_browser_mailer') and \
|
2006-04-10 14:09:05 +02:00
|
|
|
self.old_values['autodetect_browser_mailer'] is True:
|
2006-01-20 14:54:02 +01:00
|
|
|
gajim.config.set('autodetect_browser_mailer', False)
|
2006-03-17 13:15:31 +01:00
|
|
|
if self.old_values.has_key('useemoticons') and \
|
2006-04-10 14:09:05 +02:00
|
|
|
not self.old_values['useemoticons']:
|
2006-03-17 13:15:31 +01:00
|
|
|
gajim.config.set('emoticons_theme', '')
|
2006-04-10 14:09:05 +02:00
|
|
|
if self.old_values.has_key('always_compact_view_chat') and \
|
2006-04-28 21:41:35 +02:00
|
|
|
self.old_values['always_compact_view_chat'] != 'False':
|
2006-04-10 14:09:05 +02:00
|
|
|
gajim.config.set('always_hide_chat_buttons', True)
|
|
|
|
if self.old_values.has_key('always_compact_view_gc') and \
|
2006-04-28 21:41:35 +02:00
|
|
|
self.old_values['always_compact_view_gc'] != 'False':
|
2006-04-10 14:09:05 +02:00
|
|
|
gajim.config.set('always_hide_groupchat_buttons', True)
|
|
|
|
|
2006-03-25 21:29:29 +01:00
|
|
|
for account in gajim.config.get_per('accounts'):
|
|
|
|
proxies_str = gajim.config.get_per('accounts', account,
|
2006-04-05 16:54:17 +02:00
|
|
|
'file_transfer_proxies')
|
2006-03-26 12:24:42 +02:00
|
|
|
proxies = proxies_str.split(',')
|
|
|
|
for i in range(0, len(proxies)):
|
|
|
|
proxies[i] = proxies[i].strip()
|
2006-04-12 11:13:38 +02:00
|
|
|
for wrong_proxy in ['proxy65.jabber.autocom.pl',
|
|
|
|
'proxy65.jabber.ccc.de']:
|
2006-03-25 21:29:29 +01:00
|
|
|
if wrong_proxy in proxies:
|
|
|
|
proxies.remove(wrong_proxy)
|
2006-03-26 12:24:42 +02:00
|
|
|
if not 'transfer.jabber.freenet.de' in proxies:
|
|
|
|
proxies.append('transfer.jabber.freenet.de')
|
2006-03-25 21:29:29 +01:00
|
|
|
proxies_str = ', '.join(proxies)
|
|
|
|
gajim.config.set_per('accounts', account, 'file_transfer_proxies',
|
2006-04-05 16:54:17 +02:00
|
|
|
proxies_str)
|
2006-04-12 10:38:51 +02:00
|
|
|
# create unread_messages table if needed
|
|
|
|
self.assert_unread_msgs_table_exists()
|
2006-04-10 13:46:53 +02:00
|
|
|
|
2006-03-26 12:24:42 +02:00
|
|
|
gajim.config.set('version', '0.10')
|
2006-05-10 18:25:57 +02:00
|
|
|
|
2006-06-02 13:21:05 +02:00
|
|
|
def update_config_to_01011(self):
|
2006-06-11 15:01:54 +02:00
|
|
|
if self.old_values.has_key('print_status_in_muc') and \
|
|
|
|
self.old_values['print_status_in_muc'] in (True, False):
|
2006-06-02 13:21:05 +02:00
|
|
|
gajim.config.set('print_status_in_muc', 'in_and_out')
|
|
|
|
gajim.config.set('version', '0.10.1.1')
|
2006-06-10 20:18:46 +02:00
|
|
|
|
|
|
|
def update_config_to_01012(self):
|
2006-06-10 20:23:19 +02:00
|
|
|
# See [6456]
|
2006-06-12 09:37:17 +02:00
|
|
|
if self.old_values.has_key('emoticons_theme') and \
|
|
|
|
self.old_values['emoticons_theme'] == 'Disabled':
|
2006-06-10 20:18:46 +02:00
|
|
|
gajim.config.set('emoticons_theme', '')
|
|
|
|
gajim.config.set('version', '0.10.1.2')
|
2006-07-30 00:29:59 +02:00
|
|
|
|
|
|
|
def update_config_to_01013(self):
|
|
|
|
'''create table transports_cache if there is no such table'''
|
2007-01-02 18:56:26 +01:00
|
|
|
#FIXME see #2812
|
|
|
|
back = os.getcwd()
|
|
|
|
os.chdir(logger.LOG_DB_FOLDER)
|
|
|
|
con = sqlite.connect(logger.LOG_DB_FILE)
|
|
|
|
os.chdir(back)
|
2006-07-30 00:29:59 +02:00
|
|
|
cur = con.cursor()
|
|
|
|
try:
|
|
|
|
cur.executescript(
|
|
|
|
'''
|
|
|
|
CREATE TABLE transports_cache (
|
|
|
|
transport TEXT UNIQUE,
|
|
|
|
type INTEGER
|
|
|
|
);
|
|
|
|
'''
|
|
|
|
)
|
|
|
|
con.commit()
|
|
|
|
except sqlite.OperationalError, e:
|
|
|
|
pass
|
|
|
|
con.close()
|
|
|
|
gajim.config.set('version', '0.10.1.3')
|
2006-10-07 12:19:25 +02:00
|
|
|
|
2006-10-07 13:28:38 +02:00
|
|
|
def update_config_to_01014(self):
|
2006-10-07 12:19:25 +02:00
|
|
|
'''apply indeces to the logs database'''
|
2007-01-02 13:17:51 +01:00
|
|
|
print _('migrating logs database to indices')
|
2007-01-02 18:56:26 +01:00
|
|
|
#FIXME see #2812
|
|
|
|
back = os.getcwd()
|
|
|
|
os.chdir(logger.LOG_DB_FOLDER)
|
|
|
|
con = sqlite.connect(logger.LOG_DB_FILE)
|
|
|
|
os.chdir(back)
|
2006-10-07 12:19:25 +02:00
|
|
|
cur = con.cursor()
|
|
|
|
# apply indeces
|
2006-10-08 11:57:23 +02:00
|
|
|
try:
|
|
|
|
cur.executescript(
|
|
|
|
'''
|
|
|
|
CREATE INDEX idx_logs_jid_id_kind ON logs (jid_id, kind);
|
|
|
|
CREATE INDEX idx_unread_messages_jid_id ON unread_messages (jid_id);
|
|
|
|
'''
|
|
|
|
)
|
2006-10-07 12:19:25 +02:00
|
|
|
|
2006-10-08 11:57:23 +02:00
|
|
|
con.commit()
|
|
|
|
except:
|
|
|
|
pass
|
2006-10-07 12:19:25 +02:00
|
|
|
con.close()
|
|
|
|
gajim.config.set('version', '0.10.1.4')
|
2006-10-08 11:57:23 +02:00
|
|
|
|
|
|
|
def update_config_to_01015(self):
|
|
|
|
'''clean show values in logs database'''
|
2007-01-02 18:56:26 +01:00
|
|
|
#FIXME see #2812
|
|
|
|
back = os.getcwd()
|
|
|
|
os.chdir(logger.LOG_DB_FOLDER)
|
|
|
|
con = sqlite.connect(logger.LOG_DB_FILE)
|
|
|
|
os.chdir(back)
|
2006-10-08 11:57:23 +02:00
|
|
|
cur = con.cursor()
|
|
|
|
status = dict((i[5:].lower(), logger.constants.__dict__[i]) for i in \
|
|
|
|
logger.constants.__dict__.keys() if i.startswith('SHOW_'))
|
|
|
|
for show in status:
|
|
|
|
cur.execute('update logs set show = ? where show = ?;', (status[show],
|
|
|
|
show))
|
2006-10-08 15:18:32 +02:00
|
|
|
cur.execute('update logs set show = NULL where show not in (0, 1, 2, 3, 4, 5);')
|
2006-10-08 11:57:23 +02:00
|
|
|
con.commit()
|
2006-10-12 00:08:30 +02:00
|
|
|
cur.close() # remove this in 2007 [pysqlite old versions need this]
|
2006-10-08 11:57:23 +02:00
|
|
|
con.close()
|
|
|
|
gajim.config.set('version', '0.10.1.5')
|
2006-10-12 03:28:09 +02:00
|
|
|
|
|
|
|
def update_config_to_01016(self):
|
|
|
|
'''#2494 : Now we play gc_received_message sound even if
|
|
|
|
notify_on_all_muc_messages is false. Keep precedent behaviour.'''
|
|
|
|
if self.old_values.has_key('notify_on_all_muc_messages') and \
|
|
|
|
self.old_values['notify_on_all_muc_messages'] == 'False' and \
|
|
|
|
gajim.config.get_per('soundevents', 'muc_message_received', 'enabled'):
|
|
|
|
gajim.config.set_per('soundevents',\
|
|
|
|
'muc_message_received', 'enabled', False)
|
|
|
|
gajim.config.set('version', '0.10.1.6')
|
2006-11-03 20:52:39 +01:00
|
|
|
|
|
|
|
def update_config_to_01017(self):
|
|
|
|
'''trayicon_notification_on_new_messages ->
|
|
|
|
trayicon_notification_on_events '''
|
|
|
|
if self.old_values.has_key('trayicon_notification_on_new_messages'):
|
|
|
|
gajim.config.set('trayicon_notification_on_events',
|
2007-02-04 19:57:25 +01:00
|
|
|
self.old_values['trayicon_notification_on_new_messages'])
|
2006-11-03 20:52:39 +01:00
|
|
|
gajim.config.set('version', '0.10.1.7')
|
2006-11-26 10:06:47 +01:00
|
|
|
|
|
|
|
def update_config_to_01018(self):
|
|
|
|
'''chat_state_notifications -> outgoing_chat_state_notifications'''
|
|
|
|
if self.old_values.has_key('chat_state_notifications'):
|
|
|
|
gajim.config.set('outgoing_chat_state_notifications',
|
2007-02-04 19:57:25 +01:00
|
|
|
self.old_values['chat_state_notifications'])
|
2006-11-26 10:06:47 +01:00
|
|
|
gajim.config.set('version', '0.10.1.8')
|
2007-01-12 20:27:00 +01:00
|
|
|
|
|
|
|
def update_config_to_01101(self):
|
|
|
|
'''fill time_stamp from before_time and after_time'''
|
|
|
|
if self.old_values.has_key('before_time'):
|
2007-01-20 17:49:32 +01:00
|
|
|
gajim.config.set('time_stamp', '%s%%X%s ' % (
|
2007-01-12 20:27:00 +01:00
|
|
|
self.old_values['before_time'], self.old_values['after_time']))
|
|
|
|
gajim.config.set('version', '0.11.0.1')
|
2007-01-28 20:16:38 +01:00
|
|
|
|
|
|
|
def update_config_to_01102(self):
|
|
|
|
'''fill time_stamp from before_time and after_time'''
|
|
|
|
if self.old_values.has_key('ft_override_host_to_send'):
|
|
|
|
gajim.config.set('ft_add_hosts_to_send',
|
|
|
|
self.old_values['ft_override_host_to_send'])
|
|
|
|
gajim.config.set('version', '0.11.0.2')
|
2007-06-26 01:51:44 +02:00
|
|
|
|
2007-06-26 13:37:01 +02:00
|
|
|
def update_config_to_01111(self):
|
2007-06-26 01:51:44 +02:00
|
|
|
'''always_hide_chatbuttons -> compact_view'''
|
|
|
|
if self.old_values.has_key('always_hide_groupchat_buttons') and \
|
|
|
|
self.old_values.has_key('always_hide_chat_buttons'):
|
|
|
|
gajim.config.set('compact_view', self.old_values['always_hide_groupchat_buttons'] and \
|
|
|
|
self.old_values['always_hide_chat_buttons'])
|
2007-06-26 13:37:01 +02:00
|
|
|
gajim.config.set('version', '0.11.1.1')
|
2007-06-26 01:51:44 +02:00
|
|
|
|
2007-07-04 18:50:54 +02:00
|
|
|
def update_config_to_01112(self):
|
|
|
|
'''gtk+ theme is renamed to default'''
|
|
|
|
if self.old_values.has_key('roster_theme') and \
|
|
|
|
self.old_values['roster_theme'] == 'gtk+':
|
|
|
|
gajim.config.set('roster_theme', _('default'))
|
|
|
|
gajim.config.set('version', '0.11.1.2')
|
2007-07-09 23:24:47 +02:00
|
|
|
|
|
|
|
def update_config_to_01113(self):
|
|
|
|
# copy&pasted from update_config_to_01013, possibly 'FIXME see #2812' applies too
|
|
|
|
back = os.getcwd()
|
|
|
|
os.chdir(logger.LOG_DB_FOLDER)
|
|
|
|
con = sqlite.connect(logger.LOG_DB_FILE)
|
|
|
|
os.chdir(back)
|
|
|
|
cur = con.cursor()
|
|
|
|
try:
|
|
|
|
cur.executescript(
|
|
|
|
'''
|
|
|
|
CREATE TABLE caps_cache (
|
|
|
|
node TEXT,
|
|
|
|
ver TEXT,
|
|
|
|
ext TEXT,
|
|
|
|
data BLOB
|
|
|
|
);
|
|
|
|
'''
|
|
|
|
)
|
|
|
|
con.commit()
|
|
|
|
except sqlite.OperationalError, e:
|
|
|
|
pass
|
|
|
|
con.close()
|
|
|
|
gajim.config.set('version', '0.11.1.3')
|
|
|
|
|
2007-07-11 12:09:31 +02:00
|
|
|
def update_config_to_01114(self):
|
|
|
|
# add default theme if it doesn't exist
|
|
|
|
d = ['accounttextcolor', 'accountbgcolor', 'accountfont',
|
|
|
|
'accountfontattrs', 'grouptextcolor', 'groupbgcolor', 'groupfont',
|
|
|
|
'groupfontattrs', 'contacttextcolor', 'contactbgcolor', 'contactfont',
|
|
|
|
'contactfontattrs', 'bannertextcolor', 'bannerbgcolor', 'bannerfont',
|
|
|
|
'bannerfontattrs']
|
|
|
|
theme_name = _('default')
|
|
|
|
if theme_name not in gajim.config.get_per('themes'):
|
|
|
|
gajim.config.add_per('themes', theme_name)
|
|
|
|
if gajim.config.get_per('themes', 'gtk+'):
|
|
|
|
# copy from old gtk+ theme
|
|
|
|
for o in d:
|
|
|
|
val = gajim.config.get_per('themes', 'gtk+', o)
|
|
|
|
gajim.config.set_per('themes', theme_name, o, val)
|
|
|
|
gajim.config.del_per('themes', 'gtk+')
|
|
|
|
else:
|
|
|
|
# copy from default theme
|
|
|
|
theme = gajim.config.themes_default[theme_name]
|
|
|
|
for o in d:
|
|
|
|
gajim.config.set_per('themes', theme_name, o, theme[d.index(o)])
|
|
|
|
gajim.config.set('version', '0.11.1.4')
|
2007-07-13 16:44:01 +02:00
|
|
|
|
|
|
|
def update_config_to_01115(self):
|
|
|
|
# copy&pasted from update_config_to_01013, possibly 'FIXME see #2812' applies too
|
|
|
|
back = os.getcwd()
|
|
|
|
os.chdir(logger.LOG_DB_FOLDER)
|
|
|
|
con = sqlite.connect(logger.LOG_DB_FILE)
|
|
|
|
os.chdir(back)
|
|
|
|
cur = con.cursor()
|
|
|
|
try:
|
|
|
|
cur.executescript(
|
|
|
|
'''
|
|
|
|
DELETE FROM caps_cache;
|
|
|
|
'''
|
|
|
|
)
|
|
|
|
con.commit()
|
|
|
|
except sqlite.OperationalError, e:
|
|
|
|
pass
|
|
|
|
con.close()
|
|
|
|
gajim.config.set('version', '0.11.1.5')
|
2007-09-29 22:51:38 +02:00
|
|
|
|
|
|
|
def update_config_to_01121(self):
|
|
|
|
# remove old unencrypted secrets file
|
|
|
|
from common.configpaths import gajimpaths
|
|
|
|
|
|
|
|
new_file = gajimpaths['SECRETS_FILE']
|
|
|
|
|
|
|
|
old_file = os.path.dirname(new_file) + '/secrets'
|
|
|
|
|
|
|
|
if os.path.exists(old_file):
|
|
|
|
os.remove(old_file)
|
|
|
|
|
|
|
|
gajim.config.set('version', '0.11.2.1')
|
2007-10-23 17:16:39 +02:00
|
|
|
|
2007-12-26 22:30:45 +01:00
|
|
|
def update_config_to_01141(self):
|
2007-10-23 17:16:39 +02:00
|
|
|
back = os.getcwd()
|
|
|
|
os.chdir(logger.LOG_DB_FOLDER)
|
|
|
|
con = sqlite.connect(logger.LOG_DB_FILE)
|
|
|
|
os.chdir(back)
|
|
|
|
cur = con.cursor()
|
|
|
|
try:
|
|
|
|
cur.executescript(
|
|
|
|
'''
|
|
|
|
CREATE TABLE IF NOT EXISTS caps_cache (
|
|
|
|
node TEXT,
|
|
|
|
ver TEXT,
|
|
|
|
ext TEXT,
|
|
|
|
data BLOB
|
|
|
|
);
|
|
|
|
'''
|
|
|
|
)
|
|
|
|
con.commit()
|
|
|
|
except sqlite.OperationalError, e:
|
|
|
|
pass
|
|
|
|
con.close()
|
2007-12-26 22:30:45 +01:00
|
|
|
gajim.config.set('version', '0.11.4.1')
|
2007-10-23 17:16:39 +02:00
|
|
|
|
2008-01-27 21:15:17 +01:00
|
|
|
def update_config_to_01142(self):
|
|
|
|
'''next_message_received sound event is splittedin 2 events'''
|
|
|
|
gajim.config.add_per('soundevents', 'next_message_received_focused')
|
|
|
|
gajim.config.add_per('soundevents', 'next_message_received_unfocused')
|
|
|
|
if gajim.config.get_per('soundevents', 'next_message_received'):
|
|
|
|
enabled = gajim.config.get_per('soundevents', 'next_message_received',
|
|
|
|
'enabled')
|
|
|
|
path = gajim.config.get_per('soundevents', 'next_message_received',
|
|
|
|
'path')
|
|
|
|
gajim.config.del_per('soundevents', 'next_message_received')
|
|
|
|
gajim.config.set_per('soundevents', 'next_message_received_focused',
|
|
|
|
'enabled', enabled)
|
|
|
|
gajim.config.set_per('soundevents', 'next_message_received_focused',
|
|
|
|
'path', path)
|
|
|
|
gajim.config.set('version', '0.11.1.2')
|
2008-04-15 03:52:11 +02:00
|
|
|
|
|
|
|
def update_config_to_01143(self):
|
|
|
|
back = os.getcwd()
|
|
|
|
os.chdir(logger.LOG_DB_FOLDER)
|
|
|
|
con = sqlite.connect(logger.LOG_DB_FILE)
|
|
|
|
os.chdir(back)
|
|
|
|
cur = con.cursor()
|
|
|
|
try:
|
|
|
|
cur.executescript(
|
|
|
|
'''
|
|
|
|
CREATE TABLE IF NOT EXISTS rooms_last_message_time(
|
|
|
|
jid_id INTEGER PRIMARY KEY UNIQUE,
|
|
|
|
time INTEGER
|
|
|
|
);
|
|
|
|
'''
|
|
|
|
)
|
|
|
|
con.commit()
|
|
|
|
except sqlite.OperationalError, e:
|
|
|
|
pass
|
|
|
|
con.close()
|
|
|
|
gajim.config.set('version', '0.11.4.3')
|
2008-04-21 00:58:47 +02:00
|
|
|
|
|
|
|
def update_config_to_01144(self):
|
|
|
|
back = os.getcwd()
|
|
|
|
os.chdir(logger.LOG_DB_FOLDER)
|
|
|
|
con = sqlite.connect(logger.LOG_DB_FILE)
|
|
|
|
os.chdir(back)
|
|
|
|
cur = con.cursor()
|
|
|
|
try:
|
|
|
|
cur.executescript('DROP TABLE caps_cache;')
|
|
|
|
con.commit()
|
|
|
|
except sqlite.OperationalError, e:
|
|
|
|
pass
|
|
|
|
try:
|
|
|
|
cur.executescript(
|
|
|
|
'''
|
|
|
|
CREATE TABLE caps_cache (
|
|
|
|
hash_method TEXT,
|
|
|
|
hash TEXT,
|
|
|
|
data BLOB
|
|
|
|
);
|
|
|
|
'''
|
|
|
|
)
|
|
|
|
con.commit()
|
|
|
|
except sqlite.OperationalError, e:
|
|
|
|
pass
|
|
|
|
con.close()
|
|
|
|
gajim.config.set('version', '0.11.4.4')
|