本文整理汇总了Python中leap.bitmask.config.leapsettings.LeapSettings.get_enabled_services方法的典型用法代码示例。如果您正苦于以下问题:Python LeapSettings.get_enabled_services方法的具体用法?Python LeapSettings.get_enabled_services怎么用?Python LeapSettings.get_enabled_services使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类leap.bitmask.config.leapsettings.LeapSettings
的用法示例。
在下文中一共展示了LeapSettings.get_enabled_services方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Account
# 需要导入模块: from leap.bitmask.config.leapsettings import LeapSettings [as 别名]
# 或者: from leap.bitmask.config.leapsettings.LeapSettings import get_enabled_services [as 别名]
class Account():
def __init__(self, username, domain):
self._settings = LeapSettings()
self.username = username
self.domain = domain
if self.username is not None:
self.address = make_address(self.username, self.domain)
else:
self.address = self.domain
def services(self):
"""
returns a list of service name strings
TODO: this should depend not just on the domain
"""
return self._settings.get_enabled_services(self.domain)
def is_email_enabled(self):
MX_SERVICE in self.services()
def is_eip_enabled(self):
EIP_SERVICE in self.services()
示例2: PreferencesWindow
# 需要导入模块: from leap.bitmask.config.leapsettings import LeapSettings [as 别名]
# 或者: from leap.bitmask.config.leapsettings.LeapSettings import get_enabled_services [as 别名]
class PreferencesWindow(QtGui.QDialog):
"""
Window that displays the preferences.
"""
preferences_saved = QtCore.Signal()
def __init__(self, parent, username, domain, backend, soledad_started, mx,
leap_signaler):
"""
:param parent: parent object of the PreferencesWindow.
:parent type: QWidget
:param username: the user set in the login widget
:type username: unicode
:param domain: the selected domain in the login widget
:type domain: unicode
:param backend: Backend being used
:type backend: Backend
:param soledad_started: whether soledad has started or not
:type soledad_started: bool
:param mx: whether the current provider provides mx or not.
:type mx: bool
"""
QtGui.QDialog.__init__(self, parent)
self.AUTOMATIC_GATEWAY_LABEL = self.tr("Automatic")
self._username = username
self._domain = domain
self._leap_signaler = leap_signaler
self._backend = backend
self._soledad_started = soledad_started
self._mx_provided = mx
self._settings = LeapSettings()
self._backend_connect()
# Load UI
self.ui = Ui_Preferences()
self.ui.setupUi(self)
self.ui.lblPasswordChangeStatus.setVisible(False)
self.ui.lblProvidersServicesStatus.setVisible(False)
self._selected_services = set()
# Connections
self.ui.pbChangePassword.clicked.connect(self._change_password)
self.ui.cbProvidersServices.currentIndexChanged[unicode].connect(
self._populate_services)
if not self._settings.get_configured_providers():
self.ui.gbEnabledServices.setEnabled(False)
else:
self._add_configured_providers()
if self._username is None:
self._not_logged_in()
else:
self.ui.gbPasswordChange.setEnabled(True)
if self._mx_provided:
self._provides_mx()
self._select_provider_by_name(domain)
def _not_logged_in(self):
"""
Actions to perform if the user is not logged in.
"""
msg = self.tr(
"In order to change your password you need to be logged in.")
self._set_password_change_status(msg)
self.ui.gbPasswordChange.setEnabled(False)
def _provides_mx(self):
"""
Actions to perform if the provider provides MX.
"""
pw_enabled = True
enabled_services = self._settings.get_enabled_services(self._domain)
mx_name = get_service_display_name(MX_SERVICE)
if MX_SERVICE not in enabled_services:
msg = self.tr("You need to enable {0} in order to change "
"the password.".format(mx_name))
self._set_password_change_status(msg, error=True)
pw_enabled = False
else:
# check if Soledad is bootstrapped
if not self._soledad_started:
msg = self.tr(
"You need to wait until {0} is ready in "
"order to change the password.".format(mx_name))
self._set_password_change_status(msg)
pw_enabled = False
self.ui.gbPasswordChange.setEnabled(pw_enabled)
@QtCore.Slot()
def set_soledad_ready(self):
"""
TRIGGERS:
parent.soledad_ready
#.........这里部分代码省略.........
示例3: PreferencesWindow
# 需要导入模块: from leap.bitmask.config.leapsettings import LeapSettings [as 别名]
# 或者: from leap.bitmask.config.leapsettings.LeapSettings import get_enabled_services [as 别名]
#.........这里部分代码省略.........
def _populate_services(self, domain):
"""
SLOT
TRIGGERS:
self.ui.cbProvidersServices.currentIndexChanged[unicode]
Loads the services that the provider provides into the UI for
the user to enable or disable.
:param domain: the domain of the provider to load services from.
:type domain: str
"""
# We hide the maybe-visible status label after a change
self.ui.lblProvidersServicesStatus.setVisible(False)
if not domain:
return
provider_config = self._get_provider_config(domain)
if provider_config is None:
return
# set the proper connection for the 'save' button
try:
self.ui.pbSaveServices.clicked.disconnect()
except RuntimeError:
pass # Signal was not connected
save_services = partial(self._save_enabled_services, domain)
self.ui.pbSaveServices.clicked.connect(save_services)
services = get_supported(provider_config.get_services())
services_conf = self._settings.get_enabled_services(domain)
# discard changes if other provider is selected
self._selected_services = set()
# from: http://stackoverflow.com/a/13103617/687989
# remove existing checkboxes
layout = self.ui.vlServices
for i in reversed(range(layout.count())):
layout.itemAt(i).widget().setParent(None)
# add one checkbox per service and set the current configured value
for service in services:
try:
checkbox = QtGui.QCheckBox(self)
service_label = get_service_display_name(service)
checkbox.setText(service_label)
self.ui.vlServices.addWidget(checkbox)
checkbox.stateChanged.connect(
partial(self._service_selection_changed, service))
checkbox.setChecked(service in services_conf)
except ValueError:
logger.error("Something went wrong while trying to "
"load service %s" % (service,))
def _save_enabled_services(self, provider):
"""
SLOT
TRIGGERS:
self.ui.pbSaveServices.clicked
示例4: PreferencesWindow
# 需要导入模块: from leap.bitmask.config.leapsettings import LeapSettings [as 别名]
# 或者: from leap.bitmask.config.leapsettings.LeapSettings import get_enabled_services [as 别名]
class PreferencesWindow(QtGui.QDialog):
"""
Window that displays the preferences.
"""
def __init__(self, parent, srp_auth, provider_config, soledad, domain):
"""
:param parent: parent object of the PreferencesWindow.
:parent type: QWidget
:param srp_auth: SRPAuth object configured in the main app.
:type srp_auth: SRPAuth
:param provider_config: ProviderConfig object.
:type provider_config: ProviderConfig
:param soledad: Soledad instance
:type soledad: Soledad
:param domain: the selected domain in the login widget
:type domain: unicode
"""
QtGui.QDialog.__init__(self, parent)
self.AUTOMATIC_GATEWAY_LABEL = self.tr("Automatic")
self._srp_auth = srp_auth
self._settings = LeapSettings()
self._soledad = soledad
# Load UI
self.ui = Ui_Preferences()
self.ui.setupUi(self)
self.ui.lblPasswordChangeStatus.setVisible(False)
self.ui.lblProvidersServicesStatus.setVisible(False)
self._selected_services = set()
# Connections
self.ui.pbChangePassword.clicked.connect(self._change_password)
self.ui.cbProvidersServices.currentIndexChanged[unicode].connect(
self._populate_services)
if not self._settings.get_configured_providers():
self.ui.gbEnabledServices.setEnabled(False)
else:
self._add_configured_providers()
pw_enabled = False
# check if the user is logged in
if srp_auth is not None and srp_auth.get_token() is not None:
# check if provider has 'mx' ...
if provider_config.provides_mx():
enabled_services = self._settings.get_enabled_services(domain)
mx_name = get_service_display_name(MX_SERVICE)
# ... and if the user have it enabled
if MX_SERVICE not in enabled_services:
msg = self.tr("You need to enable {0} in order to change "
"the password.".format(mx_name))
self._set_password_change_status(msg, error=True)
else:
if sameProxiedObjects(self._soledad, None):
msg = self.tr(
"You need to wait until {0} is ready in "
"order to change the password.".format(mx_name))
self._set_password_change_status(msg)
else:
# Soledad is bootstrapped
pw_enabled = True
else:
pw_enabled = True
else:
msg = self.tr(
"In order to change your password you need to be logged in.")
self._set_password_change_status(msg)
self._select_provider_by_name(domain)
self.ui.gbPasswordChange.setEnabled(pw_enabled)
def set_soledad_ready(self):
"""
SLOT
TRIGGERS:
parent.soledad_ready
It notifies when the soledad object as ready to use.
"""
self.ui.lblPasswordChangeStatus.setVisible(False)
self.ui.gbPasswordChange.setEnabled(True)
def _set_password_change_status(self, status, error=False, success=False):
"""
Sets the status label for the password change.
:param status: status message to display, can be HTML
:type status: str
"""
if error:
status = "<font color='red'><b>%s</b></font>" % (status,)
elif success:
status = "<font color='green'><b>%s</b></font>" % (status,)
if not self.ui.gbPasswordChange.isEnabled():
#.........这里部分代码省略.........