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
Weblate
gajim
Commits
49925786
Commit
49925786
authored
16 years ago
by
Yann Leboulanger
Browse files
Options
Downloads
Patches
Plain Diff
store passwords in gnome keyring in another way. silently upgrade to the new way
parent
cd9c0415
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
+22
-8
22 additions, 8 deletions
src/common/passwords.py
with
22 additions
and
8 deletions
src/common/passwords.py
+
22
−
8
View file @
49925786
...
...
@@ -77,13 +77,25 @@ class GnomePasswordStorage(PasswordStorage):
set_storage
(
SimplePasswordStorage
())
return
password
try
:
attributes
=
dict
(
account_name
=
str
(
account_name
),
gajim
=
1
)
server
=
gajim
.
config
.
get_per
(
'
accounts
'
,
account_name
,
'
hostname
'
)
user
=
gajim
.
config
.
get_per
(
'
accounts
'
,
account_name
,
'
name
'
)
attributes1
=
dict
(
server
=
str
(
server
),
user
=
str
(
user
),
protocol
=
'
xmpp
'
)
attributes2
=
dict
(
account_name
=
str
(
account_name
),
gajim
=
1
)
try
:
items
=
gnomekeyring
.
find_items_sync
(
gnomekeyring
.
ITEM_GENERIC_SECRET
,
attributes
)
gnomekeyring
.
ITEM_NETWORK_PASSWORD
,
attributes1
)
except
gnomekeyring
.
Error
:
items
=
[]
try
:
items
=
gnomekeyring
.
find_items_sync
(
gnomekeyring
.
ITEM_GENERIC_SECRET
,
attributes2
)
if
items
:
# We found an old item, move it to new way of storing
password
=
items
[
0
].
secret
self
.
save_password
(
account_name
,
password
)
gnomekeyring
.
item_delete_sync
(
items
[
0
].
keyring
,
int
(
items
[
0
].
item_id
))
except
gnomekeyring
.
Error
:
items
=
[]
if
len
(
items
)
>
1
:
warnings
.
warn
(
"
multiple gnome keyring items found for account %s;
"
"
trying to use the first one...
"
...
...
@@ -100,12 +112,14 @@ class GnomePasswordStorage(PasswordStorage):
return
None
def
save_password
(
self
,
account_name
,
password
,
update
=
True
):
display_name
=
_
(
'
Gajim account %s
'
)
%
account_name
attributes
=
dict
(
account_name
=
str
(
account_name
),
gajim
=
1
)
server
=
gajim
.
config
.
get_per
(
'
accounts
'
,
account_name
,
'
hostname
'
)
user
=
gajim
.
config
.
get_per
(
'
accounts
'
,
account_name
,
'
name
'
)
display_name
=
_
(
'
XMPP account %s@%s
'
)
%
(
user
,
server
)
attributes1
=
dict
(
server
=
str
(
server
),
user
=
str
(
user
),
protocol
=
'
xmpp
'
)
try
:
auth_token
=
gnomekeyring
.
item_create_sync
(
self
.
keyring
,
gnomekeyring
.
ITEM_
GENERIC_SECRET
,
display_name
,
attributes
,
password
,
update
)
self
.
keyring
,
gnomekeyring
.
ITEM_
NETWORK_PASSWORD
,
display_name
,
attributes
1
,
password
,
update
)
except
gnomekeyring
.
DeniedError
:
set_storage
(
SimplePasswordStorage
())
storage
.
save_password
(
account_name
,
password
)
...
...
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