[nanny] Export *_custom_filte to NannyDbus



commit 7b490f330b5c92ea09edd0a2ff9bdc97dc66f189
Author: Roberto Majadas <roberto majadas openshine com>
Date:   Sun Jan 31 14:52:52 2010 +0100

    Export *_custom_filte to NannyDbus

 daemon/src/FilterManager.py |   26 ++++++++++++++++++++------
 daemon/src/NannyDBus.py     |   20 +++++++++++++++++---
 2 files changed, 37 insertions(+), 9 deletions(-)
---
diff --git a/daemon/src/FilterManager.py b/daemon/src/FilterManager.py
index 939ab50..02b421e 100644
--- a/daemon/src/FilterManager.py
+++ b/daemon/src/FilterManager.py
@@ -82,11 +82,18 @@ class FilterManager (gobject.GObject) :
             return db
 
     def add_custom_filter(self, uid, is_black, name, description, regex):
-        self.custom_filters_db.runOperation('insert into customfilters values ("%s", %s, "%s", "%s", "%s")' % (str(uid),
-                                                                                                               bool(is_black),
-                                                                                                               name,
-                                                                                                               description,
-                                                                                                               regex))                                  
+        query = self.custom_filters_db.runQuery('insert into customfilters values ("%s", %s, "%s", "%s", "%s")' % (str(uid),
+                                                                                                                   bool(is_black),
+                                                                                                                   name,
+                                                                                                                   description,
+                                                                                                                   regex))
+        block_d = BlockingDeferred(query)
+        try:
+            qr = block_d.blockOn()
+            return True
+        except:
+            print "Something goes wrong Adding Custom Filters"
+            return False
         
     def list_custom_filter(self, uid):
         query = self.custom_filters_db.runQuery("select * from customfilters where uid = '%s'" % str(uid))
@@ -106,7 +113,14 @@ class FilterManager (gobject.GObject) :
         
 
     def remove_custom_filter(self, list_id):
-        self.custom_filters_db.runOperation('delete from customfilters where id=%s' % int(list_id))    
+        query = self.custom_filters_db.runQuery('delete from customfilters where id=%s' % int(list_id))
+        block_d = BlockingDeferred(query)
+        try:
+            qr = block_d.blockOn()
+            return True
+        except:
+            print "Something goes wrong Removing Custom Filters"
+            return False
     
         
 
diff --git a/daemon/src/NannyDBus.py b/daemon/src/NannyDBus.py
index 1dbcc29..15524f0 100644
--- a/daemon/src/NannyDBus.py
+++ b/daemon/src/NannyDBus.py
@@ -109,18 +109,32 @@ class NannyDBus(dbus.service.Object):
     @dbus.service.method("org.gnome.Nanny.WebDatabase",
                          in_signature='sbsss', out_signature='b')
     def AddCustomFilter(self, uid, is_black, name, description, regex):
-        return self.quarterback.webcontent_filter.webdb.add_custom_filter(str(uid), bool(is_black), str(name),
+        return self.quarterback.filter_manager.add_custom_filter(str(uid), bool(is_black), str(name),
                                                                           str(description), str(regex))
 
     @dbus.service.method("org.gnome.Nanny.WebDatabase",
                          in_signature='s', out_signature='a(issb)')
+    def ListCustomFilters(self, uid):
+        return self.quarterback.filter_manager.list_custom_filters(int(uid))
+
+    @dbus.service.method("org.gnome.Nanny.WebDatabase",
+                         in_signature='i', out_signature='b')
+    def RemoveCustomFilter(self, list_id):
+        return self.quarterback.filter_manager.remove_custom_filter(int(list_id))
+    
+    #DEPRECATED
+    @dbus.service.method("org.gnome.Nanny.WebDatabase",
+                         in_signature='s', out_signature='a(issb)')
     def ListFilters(self, uid):
-        return self.quarterback.webcontent_filter.webdb.list_filters(int(uid))
+        return self.quarterback.filter_manager.list_custom_filters(int(uid))
 
+    #DEPRECATED
     @dbus.service.method("org.gnome.Nanny.WebDatabase",
                          in_signature='i', out_signature='b')
     def RemoveFilter(self, list_id):
-        return self.quarterback.webcontent_filter.webdb.remove_filter(int(list_id))
+        return self.quarterback.filter_manager.remove_custom_filter(int(list_id))
+
+    
 
     @dbus.service.method("org.gnome.Nanny.WebDatabase",
                          in_signature='ssss', out_signature='b')



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