From 709dba715a0daec6c9a488b30d493a3f8da63239 Mon Sep 17 00:00:00 2001
From: Yann Leboulanger <asterix@lagaule.org>
Date: Tue, 15 Sep 2009 22:26:42 +0200
Subject: [PATCH] global option alwaysauth become a per-account autoauth
 option. Fixes #5264

---
 configure.ac                      | 2 +-
 src/common/config.py              | 2 +-
 src/common/connection_handlers.py | 7 ++++---
 src/common/defs.py                | 2 +-
 src/common/optparser.py           | 9 +++++++++
 5 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/configure.ac b/configure.ac
index 7545378a66..cc04ee34bc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,5 @@
 AC_INIT([Gajim - A Jabber Instant Messager],
-		[0.12.5.1-dev],[http://trac.gajim.org/],[gajim])
+		[0.12.5.2-dev],[http://trac.gajim.org/],[gajim])
 AC_PREREQ([2.59])
 
 AC_CONFIG_HEADER(config.h)
diff --git a/src/common/config.py b/src/common/config.py
index 1f99ef702d..f2277f93e9 100644
--- a/src/common/config.py
+++ b/src/common/config.py
@@ -67,7 +67,6 @@ class Config:
 	__options = {
 		# name: [ type, default_value, help_string ]
 		'verbose': [ opt_bool, False, '', True ],
-		'alwaysauth': [ opt_bool, False ],
 		'autopopup': [ opt_bool, False ],
 		'notify_on_signin': [ opt_bool, True ],
 		'notify_on_signout': [ opt_bool, False ],
@@ -287,6 +286,7 @@ class Config:
 			'autoconnect_as': [ opt_str, 'online', _('Status used to autoconnect as. Can be online, chat, away, xa, dnd, invisible. NOTE: this option is used only if restore_last_status is disabled'), True ],
 			'restore_last_status': [ opt_bool, False, _('If enabled, restore the last status that was used.') ],
 			'autoreconnect': [ opt_bool, True ],
+			'autoauth': [ opt_bool, False, _('If True, Contacts requesting authorization will be automatically accepted.')],
 			'active': [ opt_bool, True],
 			'proxy': [ opt_str, '', '', True ],
 			'keyid': [ opt_str, '', '', True ],
diff --git a/src/common/connection_handlers.py b/src/common/connection_handlers.py
index b4576a455a..60c9fbb5cc 100644
--- a/src/common/connection_handlers.py
+++ b/src/common/connection_handlers.py
@@ -2353,13 +2353,14 @@ def _presenceCB(self, con, prs):
 
 		if ptype == 'subscribe':
 			log.debug('subscribe request from %s' % who)
-			if gajim.config.get('alwaysauth') or who.find("@") <= 0 or \
-			jid_stripped in self.jids_for_auto_auth or transport_auto_auth:
+			if gajim.config.get_per('accounts', self.name, 'autoauth') or \
+			who.find('@') <= 0 or jid_stripped in self.jids_for_auto_auth or \
+			transport_auto_auth:
 				if self.connection:
 					p = common.xmpp.Presence(who, 'subscribed')
 					p = self.add_sha(p)
 					self.connection.send(p)
-				if who.find("@") <= 0 or transport_auto_auth:
+				if who.find('@') <= 0 or transport_auto_auth:
 					self.dispatch('NOTIFY', (jid_stripped, 'offline', 'offline',
 						resource, prio, keyID, timestamp, None))
 				if transport_auto_auth:
diff --git a/src/common/defs.py b/src/common/defs.py
index e213fdab10..83ef075a35 100644
--- a/src/common/defs.py
+++ b/src/common/defs.py
@@ -27,7 +27,7 @@
 datadir = '../'
 localedir = '../po'
 
-version = '0.12.5.1-dev'
+version = '0.12.5.2-dev'
 
 import sys, os.path
 for base in ('.', 'common'):
diff --git a/src/common/optparser.py b/src/common/optparser.py
index bc455e1f65..5cedeeaca7 100644
--- a/src/common/optparser.py
+++ b/src/common/optparser.py
@@ -202,6 +202,8 @@ def update_config(self, old_version, new_version):
 			self.update_config_to_01231()
 		if old < [0, 12, 5, 1] and new >= [0, 12, 5, 1]:
 			self.update_config_to_01251()
+		if old < [0, 12, 5, 2] and new >= [0, 12, 5, 2]:
+			self.update_config_to_01252()
 
 		gajim.logger.init_vars()
 		gajim.config.set('version', new_version)
@@ -727,4 +729,11 @@ def update_config_to_01251(self):
 		con.close()
 		gajim.config.set('version', '0.12.5.1')
 
+	def update_config_to_01252(self):
+		if 'alwaysauth' in self.old_values:
+			val = self.old_values['alwaysauth']
+			for account in gajim.config.get_per('accounts'):
+				gajim.config.set_per('accounts', account, 'autoauth', val)
+		gajim.config.set('version', '0.12.5.2')
+
 # vim: se ts=3:
-- 
GitLab