Optional login/password in account
Remove login/password related attribut in Account class but still support live password if account_class in component has correct attributs. darcs-hash:20061025182516-86b55-4743189d47ba481692f16ff52f8b50903df49689.gz
This commit is contained in:
@@ -479,7 +479,9 @@ class JCLComponent(Component):
|
||||
accounts = self.account_class.select(\
|
||||
self.account_class.q.user_jid == base_from_jid \
|
||||
and self.account_class.q.name == name)
|
||||
if re.compile("\[PASSWORD\]").search(message.get_subject()) \
|
||||
if hasattr(self.account_class, 'password') \
|
||||
and hasattr(self.account_class, 'waiting_password_reply') \
|
||||
and re.compile("\[PASSWORD\]").search(message.get_subject()) \
|
||||
is not None \
|
||||
and accounts.count() == 1:
|
||||
account = list(accounts)[0]
|
||||
@@ -512,7 +514,9 @@ class JCLComponent(Component):
|
||||
show = show, \
|
||||
stanza_type = "available")
|
||||
self.stream.send(p)
|
||||
if _account.store_password == False \
|
||||
if hasattr(self.account_class, 'store_password') \
|
||||
and hasattr(self.account_class, 'password') \
|
||||
and _account.store_password == False \
|
||||
and old_status == account.OFFLINE \
|
||||
and _account.password == None :
|
||||
self._ask_password(_account, lang_class)
|
||||
@@ -520,7 +524,8 @@ class JCLComponent(Component):
|
||||
def _ask_password(self, _account, lang_class):
|
||||
"""Send a Jabber message to ask for account password
|
||||
"""
|
||||
if not _account.waiting_password_reply \
|
||||
if hasattr(self.account_class, 'waiting_password_reply') \
|
||||
and not _account.waiting_password_reply \
|
||||
and _account.status != account.OFFLINE:
|
||||
_account.waiting_password_reply = True
|
||||
msg = Message(from_jid = _account.jid, \
|
||||
|
||||
@@ -32,8 +32,8 @@ from sqlobject.dbconnection import ConnectionHub
|
||||
|
||||
from jcl.lang import Lang
|
||||
|
||||
OFFLINE = 0
|
||||
ONLINE = 1
|
||||
OFFLINE = "offline"
|
||||
ONLINE = "online"
|
||||
|
||||
# create a hub to attach a per thread connection
|
||||
hub = ConnectionHub()
|
||||
@@ -45,14 +45,16 @@ class Account(SQLObject):
|
||||
user_jid = StringCol()
|
||||
name = StringCol()
|
||||
jid = StringCol()
|
||||
login = StringCol(default = "")
|
||||
password = StringCol(default = None)
|
||||
store_password = BoolCol(default = True)
|
||||
## Not yet used first_check = BoolCol(default = True)
|
||||
__status = StringCol(default = OFFLINE, dbName = "status")
|
||||
|
||||
## Use these attributs to support volatile password
|
||||
## login = StringCol(default = "")
|
||||
## password = StringCol(default = None)
|
||||
## store_password = BoolCol(default = True)
|
||||
## waiting_password_reply = BoolCol(default = False)
|
||||
|
||||
default_lang_class = Lang.en
|
||||
first_check = True
|
||||
__status = OFFLINE
|
||||
waiting_password_reply = False
|
||||
|
||||
def get_long_name(self):
|
||||
"""Return Human readable account name"""
|
||||
@@ -73,10 +75,15 @@ class Account(SQLObject):
|
||||
def set_status(self, status):
|
||||
"""Set current Jabber status"""
|
||||
if status == OFFLINE:
|
||||
self.waiting_password_reply = False
|
||||
if not self.store_password:
|
||||
self.password = None
|
||||
if hasattr(self.__class__, 'waiting_password_reply') \
|
||||
and hasattr(self.__class__, 'store_password') \
|
||||
and hasattr(self.__class__, 'password'):
|
||||
self.waiting_password_reply = False
|
||||
if not self.store_password:
|
||||
self.password = None
|
||||
else:
|
||||
# TODO seems a bug : first_check = True only if previous status
|
||||
# was OFFLINE
|
||||
self.first_check = True
|
||||
self.__status = status
|
||||
|
||||
|
||||
Reference in New Issue
Block a user