diff --git a/src/common/configpaths.py b/src/common/configpaths.py index 9e18a18aa..55d110446 100644 --- a/src/common/configpaths.py +++ b/src/common/configpaths.py @@ -134,19 +134,22 @@ class ConfigPaths: for key in self.paths.keys(): yield (key, self[key]) - def init(self, root=None, profile=''): + def init(self, root=None, profile='', profile_separation=False): if root is not None: self.config_root = self.cache_root = self.data_root = root - if len(profile) > 0: - profile = u'.' + profile + self.init_profile(profile) + if len(profile) > 0 and profile_separation: + profile = u'.' + profile + else: + profile = '' + d = {'LOG_DB': 'logs.db', 'MY_CACERTS': 'cacerts.pem', 'MY_EMOTS': 'emoticons', 'MY_ICONSETS': 'iconsets', 'MY_MOOD_ICONSETS': 'moods', 'MY_ACTIVITY_ICONSETS': 'activities', 'PLUGINS_USER': 'plugins', - 'RNG_SEED': 'rng_seed', - 'SECRETS_FILE': 'secrets', 'MY_PEER_CERTS': 'certs'} + 'RNG_SEED': 'rng_seed'} for name in d: d[name] += profile self.add(name, TYPE_DATA, windowsify(d[name])) @@ -156,8 +159,7 @@ class ConfigPaths: self.add('MY_DATA', TYPE_DATA, '') d = {'CACHE_DB': 'cache.db', 'VCARD': 'vcards', - 'AVATAR': 'avatars', - 'PID_FILE': 'gajim.pid'} + 'AVATAR': 'avatars'} for name in d: d[name] += profile self.add(name, TYPE_CACHE, windowsify(d[name])) @@ -166,10 +168,6 @@ class ConfigPaths: else: self.add('MY_CACHE', TYPE_CACHE, '') - d = {'CONFIG_FILE': 'config', 'PLUGINS_CONFIG_DIR': 'pluginsconfig', 'MY_CERT': 'localcerts'} - for name in d: - d[name] += profile - self.add(name, TYPE_CONFIG, windowsify(d[name])) if len(profile): self.add('MY_CONFIG', TYPE_CONFIG, 'config.dir') else: @@ -194,4 +192,28 @@ class ConfigPaths: except (ImportError, AttributeError): pass + def init_profile(self, profile): + conffile = windowsify('config') + pidfile = windowsify('gajim') + secretsfile = windowsify('secrets') + pluginsconfdir = windowsify('pluginsconfig') + certsdir = windowsify(u'certs') + localcertsdir = windowsify(u'localcerts') + + if len(profile) > 0: + conffile += '.' + profile + pidfile += '.' + profile + secretsfile += '.' + profile + pluginsconfdir += '.' + profile + certsdir += u'.' + profile + localcertsdir += u'.' + profile + + pidfile += '.pid' + self.add('SECRETS_FILE', TYPE_DATA, secretsfile) + self.add('MY_PEER_CERTS', TYPE_DATA, certsdir) + self.add('PID_FILE', TYPE_CACHE, pidfile) + self.add('CONFIG_FILE', TYPE_CONFIG, conffile) + self.add('PLUGINS_CONFIG_DIR', TYPE_CONFIG, pluginsconfdir) + self.add('MY_CERT', TYPE_CONFIG, localcertsdir) + gajimpaths = ConfigPaths() diff --git a/src/gajim.py b/src/gajim.py index 150941b5c..530432949 100644 --- a/src/gajim.py +++ b/src/gajim.py @@ -130,11 +130,12 @@ from common import i18n def parseOpts(): profile_ = '' config_path_ = None - + profile_separation_ = False + try: - shortargs = 'hqvl:p:c:' + shortargs = 'hqsvl:p:c:' # add gtk/gnome session option as gtk_get_option_group is not wrapped - longargs = 'help quiet verbose loglevel= profile= config-path=' + longargs = 'help quiet separate verbose loglevel= profile= config-path=' longargs += ' class= name= screen= gtk-module= sync g-fatal-warnings' longargs += ' sm-client-id= sm-client-state-file= sm-disable' opts = getopt.getopt(sys.argv[1:], shortargs, longargs.split())[0] @@ -151,6 +152,8 @@ def parseOpts(): _('Show this help message and exit') + \ '\n -q, --quiet ' + \ _('Show only critical errors') + \ + '\n -s, --separate ' + \ + _('Separate profile files completely (even history db and plugins)') + \ '\n -v, --verbose ' + \ _('Print xml stanzas and other debug information') + \ '\n -p, --profile ' + \ @@ -163,6 +166,8 @@ def parseOpts(): sys.exit() elif o in ('-q', '--quiet'): logging_helpers.set_quiet() + elif o in ('-s', '--separate'): + profile_separation_ = True elif o in ('-v', '--verbose'): logging_helpers.set_verbose() elif o in ('-p', '--profile'): # gajim --profile name @@ -171,14 +176,14 @@ def parseOpts(): logging_helpers.set_loglevels(a) elif o in ('-c', '--config-path'): config_path_ = a - return profile_, config_path_ + return profile_, config_path_, profile_separation_ import locale -profile, config_path = parseOpts() +profile, config_path, profile_separation = parseOpts() del parseOpts import common.configpaths -common.configpaths.gajimpaths.init(config_path, profile) +common.configpaths.gajimpaths.init(config_path, profile, profile_separation) del config_path del profile