[nanny] Changes at get_pkg_filter_metadata



commit 3eb78b99821151c5764ca7315817807a9c56f6b9
Author: Roberto Majadas <roberto majadas openshine com>
Date:   Sun Jan 16 16:07:32 2011 +0100

    Changes at get_pkg_filter_metadata

 client/gnome/admin/src/ConfigureProxyDialog.py |   15 ++++++++++++---
 daemon/src/FilterManager.py                    |   22 +++++++++++++---------
 daemon/src/NannyDBus.py                        |   14 +++++++-------
 3 files changed, 32 insertions(+), 19 deletions(-)
---
diff --git a/client/gnome/admin/src/ConfigureProxyDialog.py b/client/gnome/admin/src/ConfigureProxyDialog.py
index 81dd22b..102e53a 100644
--- a/client/gnome/admin/src/ConfigureProxyDialog.py
+++ b/client/gnome/admin/src/ConfigureProxyDialog.py
@@ -171,7 +171,10 @@ class ConfigureProxyDialog (gtk.Dialog):
         
         
         for filter_id in self.dbus_client.list_pkg_filters () :
-            filter_name, filter_description = self.dbus_client.get_pkg_filter_metadata(filter_id)
+            metadata = self.dbus_client.get_pkg_filter_metadata(filter_id)
+            filter_name = _("Unknown Blacklist Name") if not metadata.has_key("name") else metadata["name"]
+            filter_description = "" if not metadata.has_key("provider") else metadata["provider"]
+            
             packaged_blacklist_model.append ((filter_id, "<b>%s</b>\n   %s" % (filter_name, filter_description)))
 
         gobject.timeout_add(1, self.__update_packaged_blacklist_model)
@@ -187,7 +190,10 @@ class ConfigureProxyDialog (gtk.Dialog):
                 included = False
                 for row in list_store:
                     if row[0] == filter_id :
-                        filter_name, filter_description = self.dbus_client.get_pkg_filter_metadata(filter_id)
+                        metadata = self.dbus_client.get_pkg_filter_metadata(filter_id)
+                        filter_name = _("Unknown Blacklist Name") if not metadata.has_key("name") else metadata["name"]
+                        filter_description = "" if not metadata.has_key("provider") else metadata["provider"]
+                        
                         row[1] = "<b>%s</b>\n   %s" % (filter_name, filter_description)
                         included = True
                         break
@@ -195,7 +201,10 @@ class ConfigureProxyDialog (gtk.Dialog):
                 if included == True:
                     continue
 
-                filter_name, filter_description = self.dbus_client.get_pkg_filter_metadata(filter_id)
+                metadata = self.dbus_client.get_pkg_filter_metadata(filter_id)
+                filter_name = _("Unknown Blacklist Name") if not metadata.has_key("name") else metadata["name"]
+                filter_description = "" if not metadata.has_key("provider") else metadata["provider"]
+
                 list_store.append ((filter_id, "<b>%s</b>\n   %s" % (filter_name, filter_description)))
             
             iter = list_store.get_iter_first()
diff --git a/daemon/src/FilterManager.py b/daemon/src/FilterManager.py
index 011ad5d..9efdbcf 100644
--- a/daemon/src/FilterManager.py
+++ b/daemon/src/FilterManager.py
@@ -28,6 +28,7 @@ import gio
 import os
 import hashlib
 import sys
+import copy
 import json
 
 from urlparse import urlparse
@@ -349,21 +350,24 @@ class FilterManager (gobject.GObject) :
             ret.append(x)
                 
         return ret
-    
+
     def get_pkg_filter_metadata(self, pkg_id):
+        if pkg_id not in self.pkg_filters_conf.keys() :
+            return {}
+
         try:
             if self.pkg_filters_conf[pkg_id]["pkg_info"].has_key("metadata"):
-                if self.pkg_filters_conf[pkg_id]["status"] == PKG_STATUS_INSTALLING :
-                    ret = [self.pkg_filters_conf[pkg_id]["pkg_info"]["metadata"]["name"],
-                           self.pkg_filters_conf[pkg_id]["pkg_info"]["metadata"]["provider"] + " (Installing new blacklist)"]
-                else:
-                    ret = [self.pkg_filters_conf[pkg_id]["pkg_info"]["metadata"]["name"],
-                           self.pkg_filters_conf[pkg_id]["pkg_info"]["metadata"]["provider"]]
-                return ret
+                
+                metadata = copy.deepcopy(self.pkg_filters_conf[pkg_id]["pkg_info"]["metadata"])
+                metadata["status"] = self.pkg_filters_conf[pkg_id]["status"]
+                
+                return metadata
         except:
             pass
 
-        return [pkg_id, 'Unknown information']
+        return {"name" : "Unknown", 
+                "provider" : "Unknown", 
+                "status" : self.pkg_filters_conf[pkg_id]["status"]}
     
     def set_pkg_filter_metadata(self, pkg_id, name, description):
         #Deprecated !!
diff --git a/daemon/src/NannyDBus.py b/daemon/src/NannyDBus.py
index 778c293..363c0e0 100644
--- a/daemon/src/NannyDBus.py
+++ b/daemon/src/NannyDBus.py
@@ -265,16 +265,16 @@ class NannyDBus(dbus.service.Object):
         return self.quarterback.filter_manager.list_pkg_filter()
 
     @dbus.service.method("org.gnome.Nanny.WebDatabase",
-                         in_signature='s', out_signature='ss')
+                         in_signature='s', out_signature='a{sv}')
     def GetPkgFilterMetadata(self, pkg_id):
         return self.quarterback.filter_manager.get_pkg_filter_metadata(str(pkg_id))
 
-    @dbus.service.method("org.gnome.Nanny.WebDatabase",
-                         in_signature='sss', out_signature='b',
-                         sender_keyword='sender', connection_keyword='conn')
-    def SetPkgFilterMetadata(self, pkg_id, name, description, sender=None, conn=None):
-        self._check_polkit_privilege(sender, conn, 'org.gnome.nanny.admin')
-        return self.quarterback.filter_manager.set_pkg_filter_metadata(str(pkg_id), unicode(name), unicode(description))
+#     @dbus.service.method("org.gnome.Nanny.WebDatabase",
+#                          in_signature='sss', out_signature='b',
+#                          sender_keyword='sender', connection_keyword='conn')
+#     def SetPkgFilterMetadata(self, pkg_id, name, description, sender=None, conn=None):
+#         self._check_polkit_privilege(sender, conn, 'org.gnome.nanny.admin')
+#         return self.quarterback.filter_manager.set_pkg_filter_metadata(str(pkg_id), unicode(name), unicode(description))
 
     @dbus.service.method("org.gnome.Nanny.WebDatabase",
                          in_signature='ss', out_signature='a(sb)')



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