Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gajim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
norstbox
gajim
Commits
e0e50347
Commit
e0e50347
authored
18 years ago
by
Yann Leboulanger
Browse files
Options
Downloads
Patches
Plain Diff
[gjc] handle the case when gnomekeyring is present, but daemon is not running
parent
6d1097f1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/common/passwords.py
+27
-4
27 additions, 4 deletions
src/common/passwords.py
with
27 additions
and
4 deletions
src/common/passwords.py
+
27
−
4
View file @
e0e50347
...
...
@@ -25,8 +25,14 @@ except ImportError:
else
:
USER_HAS_GNOMEKEYRING
=
True
class
PasswordStorage
(
object
):
def
get_password
(
self
,
account_name
):
raise
NotImplementedError
def
save_password
(
self
,
account_name
,
password
):
raise
NotImplementedError
class
SimplePasswordStorage
(
object
):
class
SimplePasswordStorage
(
PasswordStorage
):
def
get_password
(
self
,
account_name
):
return
gajim
.
config
.
get_per
(
'
accounts
'
,
account_name
,
'
password
'
)
...
...
@@ -35,7 +41,7 @@ class SimplePasswordStorage(object):
gajim
.
connections
[
account_name
].
password
=
password
class
GnomePasswordStorage
(
object
):
class
GnomePasswordStorage
(
PasswordStorage
):
def
__init__
(
self
):
self
.
keyring
=
gnomekeyring
.
get_default_keyring_sync
()
...
...
@@ -49,13 +55,21 @@ class GnomePasswordStorage(object):
except
ValueError
:
password
=
conf
## migrate the password over to keyring
self
.
save_password
(
account_name
,
password
,
update
=
False
)
try
:
self
.
save_password
(
account_name
,
password
,
update
=
False
)
except
gnomekeyring
.
NoKeyringDaemonError
:
## no keyring daemon: in the future, stop using it
set_storage
(
SimplePasswordStorage
())
return
password
try
:
return
gnomekeyring
.
item_get_info_sync
(
self
.
keyring
,
auth_token
).
get_secret
()
except
gnomekeyring
.
DeniedError
:
return
None
except
gnomekeyring
.
NoKeyringDaemonError
:
## no keyring daemon: in the future, stop using it
set_storage
(
SimplePasswordStorage
())
return
None
def
save_password
(
self
,
account_name
,
password
,
update
=
True
):
display_name
=
_
(
'
Gajim account %s
'
)
%
account_name
...
...
@@ -72,11 +86,20 @@ def get_storage():
global
storage
if
storage
is
None
:
# None is only in first time get_storage is called
if
USER_HAS_GNOMEKEYRING
:
storage
=
GnomePasswordStorage
()
try
:
storage
=
GnomePasswordStorage
()
except
gnomekeyring
.
NoKeyringDaemonError
:
storage
=
SimplePasswordStorage
()
else
:
storage
=
SimplePasswordStorage
()
return
storage
def
set_storage
(
storage_
):
global
storage
assert
isinstance
(
storage
,
PasswordStorage
)
storage
=
storage_
def
get_password
(
account_name
):
return
get_storage
().
get_password
(
account_name
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment