Helpviewer/Passwords/PasswordManager.py

changeset 492
01f3384d535a
parent 414
8c91e942d2da
child 537
72b32daeb8d6
equal deleted inserted replaced
491:ac476c22d392 492:01f3384d535a
74 """ 74 """
75 Class implementing the password manager. 75 Class implementing the password manager.
76 76
77 @signal changed() emitted to indicate a change 77 @signal changed() emitted to indicate a change
78 """ 78 """
79 changed = pyqtSignal()
80
79 SEPARATOR = "====================" 81 SEPARATOR = "===================="
80 FORMS = "=====FORMS=====" 82 FORMS = "=====FORMS====="
81 NEVER = "=====NEVER=====" 83 NEVER = "=====NEVER====="
82 84
83 def __init__(self, parent = None): 85 def __init__(self, parent = None):
92 self.__loginForms = {} 94 self.__loginForms = {}
93 self.__never = [] 95 self.__never = []
94 self.__loaded = False 96 self.__loaded = False
95 self.__saveTimer = AutoSaver(self, self.save) 97 self.__saveTimer = AutoSaver(self, self.save)
96 98
97 self.connect(self, SIGNAL("changed()"), self.__saveTimer.changeOccurred) 99 self.changed.connect(self.__saveTimer.changeOccurred)
98 100
99 def clear(self): 101 def clear(self):
100 """ 102 """
101 Public slot to clear the saved passwords. 103 Public slot to clear the saved passwords.
102 """ 104 """
107 self.__loginForms = {} 109 self.__loginForms = {}
108 self.__never = [] 110 self.__never = []
109 self.__saveTimer.changeOccurred() 111 self.__saveTimer.changeOccurred()
110 self.__saveTimer.saveIfNeccessary() 112 self.__saveTimer.saveIfNeccessary()
111 113
112 self.emit(SIGNAL("changed()")) 114 self.changed.emit()
113 115
114 def getLogin(self, url, realm): 116 def getLogin(self, url, realm):
115 """ 117 """
116 Public method to get the login credentials. 118 Public method to get the login credentials.
117 119
140 if not self.__loaded: 142 if not self.__loaded:
141 self.__load() 143 self.__load()
142 144
143 key = self.__createKey(url, realm) 145 key = self.__createKey(url, realm)
144 self.__logins[key] = (username, Utilities.pwEncode(password)) 146 self.__logins[key] = (username, Utilities.pwEncode(password))
145 self.emit(SIGNAL("changed()")) 147 self.changed.emit()
146 148
147 def __createKey(self, url, realm): 149 def __createKey(self, url, realm):
148 """ 150 """
149 Private method to create the key string for the login credentials. 151 Private method to create the key string for the login credentials.
150 152
264 """ 266 """
265 if site in self.__logins: 267 if site in self.__logins:
266 del self.__logins[site] 268 del self.__logins[site]
267 if site in self.__loginForms: 269 if site in self.__loginForms:
268 del self.__loginForms[site] 270 del self.__loginForms[site]
269 self.emit(SIGNAL("changed()")) 271 self.changed.emit()
270 272
271 def allSiteNames(self): 273 def allSiteNames(self):
272 """ 274 """
273 Public method to get a list of all site names. 275 Public method to get a list of all site names.
274 276
401 password = element[1] 403 password = element[1]
402 form.elements[index] = (element[0], "--PASSWORD--") 404 form.elements[index] = (element[0], "--PASSWORD--")
403 if user and password: 405 if user and password:
404 self.__logins[key] = (user, Utilities.pwEncode(password)) 406 self.__logins[key] = (user, Utilities.pwEncode(password))
405 self.__loginForms[key] = form 407 self.__loginForms[key] = form
406 self.emit(SIGNAL("changed()")) 408 self.changed.emit()
407 409
408 def __stripUrl(self, url): 410 def __stripUrl(self, url):
409 """ 411 """
410 Private method to strip off all unneeded parts of a URL. 412 Private method to strip off all unneeded parts of a URL.
411 413

eric ide

mercurial