[nanny] Get|SetPkgFilterMetadata exported to Dbus
- From: Roberto Majadas <telemaco src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [nanny] Get|SetPkgFilterMetadata exported to Dbus
- Date: Mon, 1 Feb 2010 15:25:26 +0000 (UTC)
commit 908a97c78487c6128a327476bda41b311c244955
Author: Roberto Majadas <roberto majadas openshine com>
Date: Mon Feb 1 15:32:07 2010 +0100
Get|SetPkgFilterMetadata exported to Dbus
daemon/src/FilterManager.py | 38 +++++++++++++++++++++++++++-----------
daemon/src/NannyDBus.py | 12 +++++++++++-
2 files changed, 38 insertions(+), 12 deletions(-)
---
diff --git a/daemon/src/FilterManager.py b/daemon/src/FilterManager.py
index 483dc31..d076cd5 100644
--- a/daemon/src/FilterManager.py
+++ b/daemon/src/FilterManager.py
@@ -248,15 +248,20 @@ class FilterManager (gobject.GObject) :
ro = True
else:
ro = False
+
+ ret.append([unicode(x), ro])
- path = os.path.dirname(x)
- if not os.path.exists(os.path.join(path, "filters.metadata")) :
- ret.append([unicode(x), "", "", ro])
- continue
+ return ret
- name = ""
- description = ""
-
+ def get_pkg_filter_metadata(self, pkg_id):
+ path = os.path.dirname(pkg_id)
+ if not os.path.exists(path) :
+ return ['', '']
+
+ name = ""
+ description = ""
+
+ if os.path.exists(os.path.join(path, "filters.metadata")) :
fd = open(os.path.join(path, "filters.metadata"), "r")
for line in fd.readlines():
l = line.strip("\n")
@@ -267,10 +272,21 @@ class FilterManager (gobject.GObject) :
else:
continue
fd.close()
-
- ret.append([unicode(x), name, description, ro])
-
- return ret
+
+ return [name, description]
+
+ def set_pkg_filter_metadata(self, pkg_id, name, description):
+ for id, ro in self.list_pkg_filter() :
+ if id == pkg_id and ro == False:
+ path = os.path.dirname(pkg_id)
+ if os.path.exists(path) :
+ fd = open(os.path.join(path, "filters.metadata"), "w")
+ fd.write("Name=%s\n" % name)
+ fd.write("Comment=%s\n" % description)
+ fd.close()
+ return True
+
+ return False
def get_pkg_filter_user_categories(self, pkg_id, uid):
try:
diff --git a/daemon/src/NannyDBus.py b/daemon/src/NannyDBus.py
index 7e73db2..8623dc9 100644
--- a/daemon/src/NannyDBus.py
+++ b/daemon/src/NannyDBus.py
@@ -137,11 +137,21 @@ class NannyDBus(dbus.service.Object):
return self.quarterback.filter_manager.add_pkg_filter(name, description, path)
@dbus.service.method("org.gnome.Nanny.WebDatabase",
- in_signature='', out_signature='a(sssb)')
+ in_signature='', out_signature='a(sb)')
def ListPkgFilters(self):
return self.quarterback.filter_manager.list_pkg_filter()
@dbus.service.method("org.gnome.Nanny.WebDatabase",
+ in_signature='s', out_signature='ss')
+ def GetPkgFilterMetadata(self, pkg_id):
+ return self.quarterback.filter_manager.get_pkg_filter_metadata(pkg_id)
+
+ @dbus.service.method("org.gnome.Nanny.WebDatabase",
+ in_signature='sss', out_signature='b')
+ def SetPkgFilterMetadata(self, pkg_id, name, description):
+ return self.quarterback.filter_manager.set_pkg_filter_metadata(pkg_id, name, description)
+
+ @dbus.service.method("org.gnome.Nanny.WebDatabase",
in_signature='ss', out_signature='asas')
def GetPkgFilterUserCategories(self, pkg_id, uid):
return self.quarterback.filter_manager.get_pkg_filter_user_categories(unicode(pkg_id),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]