~gm-notify-maintainers/gm-notify/1.0

« back to all changes in this revision

Viewing changes to gm_notify_keyring.py

  • Committer: Mateusz Balbus
  • Author(s): Mateusz Balbus
  • Date: 2015-11-06 14:41:13 UTC
  • mto: This revision was merged to the branch mainline in revision 81.
  • Revision ID: devnull@localhost-20151106144113-po958qabhyou4uwl
[#5] Added possibility to edit existing user

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
            credentials_list.append(Credentials(d["user"], item.secret))
50
50
        return credentials_list
51
51
    
 
52
    def get_all_users(self):
 
53
        attrs = attributes({"server": self._server, "protocol": self._protocol})
 
54
        result, items = GnomeKeyring.find_items_sync(GnomeKeyring.ItemType.NETWORK_PASSWORD, attrs)
 
55
        if len(items) == 0:
 
56
            raise KeyringException("Credentials not found")
 
57
        users_list = []
 
58
        for item in items:
 
59
            d = dict_from_attributes(item.attributes)
 
60
            users_list.append(d["user"])
 
61
        return users_list
 
62
    
 
63
    def get_credentials(self, user):
 
64
        attrs = attributes({
 
65
                            "user" : user,
 
66
                            "server": self._server,
 
67
                            "protocol": self._protocol
 
68
                            })
 
69
        result, items = GnomeKeyring.find_items_sync(GnomeKeyring.ItemType.NETWORK_PASSWORD, attrs)
 
70
        if len(items) == 0:
 
71
            raise KeyringException("Credentials not found")
 
72
        d = dict_from_attributes(items[0].attributes)
 
73
        return Credentials(d["user"], items[0].secret) 
 
74
    
52
75
    def delete_all_credentials(self):
53
76
        attrs = attributes({"server": self._server, "protocol": self._protocol})
54
77
        result, items = GnomeKeyring.find_items_sync(GnomeKeyring.ItemType.NETWORK_PASSWORD, attrs)