def getExceptions(self, policy, category=None, categoryPolicy=None): """Convenience method to get the exception dict""" from lunchinator.privacy import PrivacySettings return PrivacySettings.get().getExceptions(self, category, policy, categoryPolicy=categoryPolicy)
def getAskForConfirmation(self, category=None, categoryPolicy=None): """Convenience method to get the 'ask for confirmation' state""" from lunchinator.privacy import PrivacySettings return PrivacySettings.get().getAskForConfirmation(self, category, categoryPolicy=categoryPolicy)
def getPeerState(self, peerID, category=None): """Convenience method to get the peer's privacy state""" from lunchinator.privacy import PrivacySettings return PrivacySettings.get().getPeerState(peerID, self, category)
def getPrivacyPolicy(self, category=None, categoryPolicy=None): """Convenience method to get the privacy policy""" from lunchinator.privacy import PrivacySettings return PrivacySettings.get().getPolicy(self, category, categoryPolicy=categoryPolicy)
def usesPrivacyCategories(self): """Returns True if the current privacy policy uses categories.""" from lunchinator.privacy import PrivacySettings policy = PrivacySettings.get().getPolicy(self, None, categoryPolicy=PrivacySettings.CATEGORY_NEVER) return policy == PrivacySettings.POLICY_BY_CATEGORY
def save_options_widget_data(self, **_kwargs): get_notification_center().disconnectPrivacySettingsChanged(self._settingsChanged) PrivacySettings.get().save() get_notification_center().connectPrivacySettingsChanged(self._settingsChanged) self._settingsChanged()
def _settingsChanged(self, _=None, __=None): self.set_hidden_option(u"json", PrivacySettings.get().getJSON(), convert=False)
def discard_changes(self): PrivacySettings.get().discard()
def activate(self): iface_general_plugin.activate(self) PrivacySettings.initialize(self.hidden_options[u"json"]) get_notification_center().connectPrivacySettingsChanged(self._settingsChanged)
class TestAction(PeerAction): def getName(self): return "Test Action" def getIcon(self): from PyQt4.QtGui import QCommonStyle, QStyle style = QCommonStyle() return style.standardIcon(QStyle.SP_MessageBoxWarning) def getMessagePrefix(self): return "TEST" def getPrivacyCategories(self): return (u"Category 1", u"Category 2") def hasCategories(self): return True def getCategoryFromMessage(self, _msgData): return u"Category 1" initializeLogger() w = privacy() testAction = TestAction() testAction._pluginObject = w testAction._pluginName = "Test Plugin" PeerActions.get()._peerActions["Test Plugin"] = [testAction] w.run_options_widget() PrivacySettings.get().save(notify=False) # don't notify, no deadlock print PrivacySettings.get()._settings