summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/config/leapsettings.py
diff options
context:
space:
mode:
authorTomás Touceda <chiiph@leap.se>2014-04-04 16:58:18 -0300
committerTomás Touceda <chiiph@leap.se>2014-04-04 16:58:18 -0300
commit81715dc47d77934c4f67d2527a56c28f58f0345d (patch)
tree6e66940af735e089803c5ce05ad1ce1df16c9d1e /src/leap/bitmask/config/leapsettings.py
parent496036f15cf257d16b6594770812da64a249280c (diff)
parenteb4cdab9c6b8ff66bb4667cc6195d2c366122540 (diff)
Merge branch 'release-0.5.0'0.5.0
Diffstat (limited to 'src/leap/bitmask/config/leapsettings.py')
-rw-r--r--src/leap/bitmask/config/leapsettings.py38
1 files changed, 35 insertions, 3 deletions
diff --git a/src/leap/bitmask/config/leapsettings.py b/src/leap/bitmask/config/leapsettings.py
index c524425e..13a1e99e 100644
--- a/src/leap/bitmask/config/leapsettings.py
+++ b/src/leap/bitmask/config/leapsettings.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# leapsettings.py
-# Copyright (C) 2013 LEAP
+# Copyright (C) 2013, 2014 LEAP
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -14,9 +14,8 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
"""
-QSettings abstraction
+QSettings abstraction.
"""
import os
import logging
@@ -70,6 +69,7 @@ class LeapSettings(object):
GATEWAY_KEY = "Gateway"
PINNED_KEY = "Pinned"
SKIPFIRSTRUN_KEY = "SkipFirstRun"
+ UUIDFORUSER_KEY = "%s/%s_uuid"
# values
GATEWAY_AUTOMATIC = "Automatic"
@@ -353,3 +353,35 @@ class LeapSettings(object):
"""
leap_assert_type(skip, bool)
self._settings.setValue(self.SKIPFIRSTRUN_KEY, skip)
+
+ def get_uuid(self, username):
+ """
+ Gets the uuid for a given username.
+
+ :param username: the full user identifier in the form user@provider
+ :type username: basestring
+ """
+ leap_assert("@" in username,
+ "Expected username in the form user@provider")
+ user, provider = username.split('@')
+ return self._settings.value(
+ self.UUIDFORUSER_KEY % (provider, user), "")
+
+ def set_uuid(self, username, value):
+ """
+ Sets the uuid for a given username.
+
+ :param username: the full user identifier in the form user@provider
+ :type username: str or unicode
+ :param value: the uuid to save or None to remove it
+ :type value: str or unicode or None
+ """
+ leap_assert("@" in username,
+ "Expected username in the form user@provider")
+ user, provider = username.split('@')
+ key = self.UUIDFORUSER_KEY % (provider, user)
+ if value is None:
+ self._settings.remove(key)
+ else:
+ leap_assert(len(value) > 0, "We cannot save an empty uuid")
+ self._settings.setValue(key, value)