[kupfer] Clear cache in Gmail and Picasa plugins when User/Pass changes



commit cb5ca4549172119aaa85bef393c9da9e389e950d
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Sun Jun 13 18:26:41 2010 +0200

    Clear cache in Gmail and Picasa plugins when User/Pass changes

 kupfer/plugin/gmail/__init__.py         |   10 +++++++++-
 kupfer/plugin/google_picasa/__init__.py |    6 ++++++
 kupfer/plugin_support.py                |    7 ++++++-
 3 files changed, 21 insertions(+), 2 deletions(-)
---
diff --git a/kupfer/plugin/gmail/__init__.py b/kupfer/plugin/gmail/__init__.py
index 54a9b29..3374a18 100644
--- a/kupfer/plugin/gmail/__init__.py
+++ b/kupfer/plugin/gmail/__init__.py
@@ -38,7 +38,7 @@ GMAIL_NEW_MAIL_URL = \
 
 
 def is_plugin_configured():
-	''' Chec is plugin is configuret (user name and password is configured) '''
+	''' Check if plugin is configured (user name and password is configured) '''
 	upass = __kupfer_settings__['userpass']
 	return bool(upass and upass.username and upass.password)
 
@@ -144,6 +144,14 @@ class GoogleContactsSource(ToplevelGroupingSource):
 		self._version = 4
 		self._contacts = []
 
+	def initialize(self):
+		__kupfer_settings__.connect("plugin-setting-changed", self._changed)
+
+	def _changed(self, settings, key, value):
+		if key == "userpass":
+			self._contacts = []
+			self.mark_for_update()
+
 	def get_items(self):
 		if is_plugin_configured():
 			return self._contacts
diff --git a/kupfer/plugin/google_picasa/__init__.py b/kupfer/plugin/google_picasa/__init__.py
index ae2b473..7b8acdf 100644
--- a/kupfer/plugin/google_picasa/__init__.py
+++ b/kupfer/plugin/google_picasa/__init__.py
@@ -406,6 +406,12 @@ class PicasaUsersSource(Source):
 	def initialize(self):
 		# fill loader cache by source cache
 		PicasaDataCache.data = self.cached_items or []
+		__kupfer_settings__.connect("plugin-setting-changed", self._changed)
+
+	def _changed(self, settings, key, value):
+		if key == "userpass":
+			PicasaDataCache.data = []
+			self.mark_for_update()
 
 	def get_items(self):
 		if is_plugin_configured():
diff --git a/kupfer/plugin_support.py b/kupfer/plugin_support.py
index 598024f..d494076 100644
--- a/kupfer/plugin_support.py
+++ b/kupfer/plugin_support.py
@@ -19,6 +19,11 @@ class PluginSettings (gobject.GObject, pretty.OutputMixin):
 
 	Setting values are accessed by the getitem operator [] with
 	the setting's 'key' attribute
+
+	Signals:
+
+		plugin-setting-changed: key, value
+
 	"""
 	__gtype_name__ = "PluginSettings"
 
@@ -90,7 +95,7 @@ class PluginSettings (gobject.GObject, pretty.OutputMixin):
 		self.connect("plugin-setting-changed", callback, *args)
 
 
-# Section, Key, Value
+# Signature: Key, Value
 gobject.signal_new("plugin-setting-changed", PluginSettings,
 		gobject.SIGNAL_RUN_LAST, gobject.TYPE_BOOLEAN,
 		(gobject.TYPE_STRING, gobject.TYPE_PYOBJECT))



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]