hotssh r41 - trunk/hotssh



Author: walters
Date: Tue Jul 29 17:05:15 2008
New Revision: 41
URL: http://svn.gnome.org/viewvc/hotssh?rev=41&view=rev

Log:
Don't try to associate favicons with host keys, just use hostname

We can't rely on having the hostname->key mapping unfortunately right
now.


Modified:
   trunk/hotssh/sshwindow.py

Modified: trunk/hotssh/sshwindow.py
==============================================================================
--- trunk/hotssh/sshwindow.py	(original)
+++ trunk/hotssh/sshwindow.py	Tue Jul 29 17:05:15 2008
@@ -20,6 +20,7 @@
 import locale,threading,subprocess,time
 import signal,tempfile,shutil,stat,pwd
 import datetime,gettext,sha,commands,errno
+import urllib
 from StringIO import StringIO
 import xml.dom.minidom
 
@@ -232,44 +233,35 @@
             self.__hostcache_ts_size = ts_size
         return self.__hostcache.iterkeys()
 
-    def get_favicon_for_host(self, host, port=None):
-        hostport = hostport_pair_to_string(host, port)
-        if self.__hostcache is None or (hostport not in self.__hostcache.iterkeys()):
-            return None
-        return self.get_favicon_for_hostkey(*self.__hostcache[hostport])
-
-    def render_cached_favicon(self, path):
-        bn = os.path.basename(path)
-        if bn not in self.__pixbufcache:
-            self.__pixbufcache[bn] = gtk.gdk.pixbuf_new_from_file_at_size(path, 16, 16)
-        return self.__pixbufcache[bn]
+    def __force_host_read(self):
+        self.get_hosts()
 
-    def __get_favicon_path(self, hostkey_type, hostkey):
-        hostkey_hash = sha.new(hostkey_type+hostkey).hexdigest()
-        return os.path.join(self.__get_favicon_cache(), hostkey_hash + '.png')
-
-    def get_favicon_for_hostkey(self, hostkey_type, hostkey):
+    def get_favicon_for_host(self, host, port=None):
         cache = self.__get_favicon_cache()
         if cache is None:
             return None
-        path = self.__get_favicon_path(hostkey_type, hostkey)
+        path = self.__get_favicon_path(host, port)
         try:
             stbuf = os.stat(path)
         except:
             return None
         return (path, stbuf[stat.ST_MTIME])
 
-    def save_favicon(self, host, port, favicon):
-        hostport = hostport_pair_to_string(host, port)
-        args = list(self.__hostcache[hostport])
-        args.append(favicon)
-        return self.save_favicon_for_hostkey(*args)
+    def render_cached_favicon(self, path):
+        bn = os.path.basename(path)
+        if bn not in self.__pixbufcache:
+            self.__pixbufcache[bn] = gtk.gdk.pixbuf_new_from_file_at_size(path, 16, 16)
+        return self.__pixbufcache[bn]
+
+    def __get_favicon_path(self, hostname, port):
+        key = urllib.quote_plus(hostname)
+        return os.path.join(self.__get_favicon_cache(), key + '.png')
 
-    def save_favicon_for_hostkey(self, hostkey_type, hostkey, favicon_tmppath):
+    def save_favicon(self, host, port, favicon_tmppath):
         cache = self.__get_favicon_cache()
         if cache is None:
             return None
-        path = self.__get_favicon_path(hostkey_type, hostkey)
+        path = self.__get_favicon_path(host, port)
         shutil.move(favicon_tmppath, path)
         self.emit('changed')
         return path



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