[tracker] Updated RSS reader example to new tracker API



commit fba61a56b650db0dbe2a8336b9ffe12d29396749
Author: Ivan Frade <ivan frade nokia com>
Date:   Tue Oct 13 15:40:33 2009 +0300

    Updated RSS reader example to new tracker API
    
    Author: J. A. Suarez <jasuarez igalia com>

 python/rss_reader/README             |    7 ++++++-
 python/rss_reader/initial-data.ttl   |    5 +++--
 python/rss_reader/main.py            |   12 ++++++------
 python/rss_reader/signaler.py        |   10 +++++-----
 python/rss_reader/tracker_backend.py |   20 ++++++++++----------
 5 files changed, 30 insertions(+), 24 deletions(-)
---
diff --git a/python/rss_reader/README b/python/rss_reader/README
index 9082447..2f86e83 100644
--- a/python/rss_reader/README
+++ b/python/rss_reader/README
@@ -22,4 +22,9 @@ into tracker (using the sparql interface).
      with -r or remove the DBs, you need to load the file
      initial-data.ttl. For instance with this command:
 
-dbus-send --print-reply --dest=org.freedesktop.Tracker /org/freedesktop/Tracker/Metadata org.freedesktop.Tracker.Metadata.Import string:"/x/y/z/initial-data.ttl"
+dbus-send --print-reply --dest=org.freedesktop.Tracker1 /org/freedesktop/Tracker1/Resources org.freedesktop.Tracker1.Resources.Load string:"/x/y/z/initial-data.ttl"
+
+or more easily:
+
+tracker-import /x/y/z/initial-data.ttl
+
diff --git a/python/rss_reader/initial-data.ttl b/python/rss_reader/initial-data.ttl
index cde3e9d..42b238b 100644
--- a/python/rss_reader/initial-data.ttl
+++ b/python/rss_reader/initial-data.ttl
@@ -8,12 +8,13 @@
 @prefix nie: <http://www.semanticdesktop.org/ontologies/2007/01/19/nie#>.
 @prefix ncal: <http://www.semanticdesktop.org/ontologies/2007/04/02/ncal#>.
 @prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
+ prefix mfo: <http://www.tracker-project.org/temp/mfo#>.
 
-<http://maemo.org/news/planet-maemo/atom.xml> a nmo:FeedChannel;
+<http://maemo.org/news/planet-maemo/atom.xml> a mfo:FeedChannel;
         nie:title "Planet Maemo";
         nie:description "Blog entries from Maemo community";
         nie:contentLastModified "2009-03-11T20:20:55+00:00".
 
-<http://planet.gnome.org/atom.xml> a nmo:FeedChannel;
+<http://planet.gnome.org/atom.xml> a mfo:FeedChannel;
         nie:title "Planet GNOME";
         nie:contentLastModified "2009-03-11T18:29:08+00:00".
diff --git a/python/rss_reader/main.py b/python/rss_reader/main.py
index c38247a..13be60e 100755
--- a/python/rss_reader/main.py
+++ b/python/rss_reader/main.py
@@ -191,18 +191,18 @@ if __name__ == "__main__":
     bus = dbus.SessionBus (dbus_loop)
     bus.add_signal_receiver (notification_addition,
                              signal_name="SubjectsAdded",
-                             dbus_interface="org.freedesktop.Tracker.Resources.Class",
-                             path="/org/freedesktop/Tracker/Resources/Classes/nmo/FeedMessage")
+                             dbus_interface="org.freedesktop.Tracker1.Resources.Class",
+                             path="/org/freedesktop/Tracker1/Resources/Classes/mfo/FeedMessage")
 
     bus.add_signal_receiver (notification_removal,
                              signal_name="SubjectsRemoved",
-                             dbus_interface="org.freedesktop.Tracker.Resources.Class",
-                             path="/org/freedesktop/Tracker/Resources/Classes/nmo/FeedMessage")
+                             dbus_interface="org.freedesktop.Tracker1.Resources.Class",
+                             path="/org/freedesktop/Tracker1/Resources/Classes/mfo/FeedMessage")
 
     bus.add_signal_receiver (notification_update,
                              signal_name="SubjectsChanged",
-                             dbus_interface="org.freedesktop.Tracker.Resources.Class",
-                             path="/org/freedesktop/Tracker/Resources/Classes/nmo/FeedMessage")
+                             dbus_interface="org.freedesktop.Tracker1.Resources.Class",
+                             path="/org/freedesktop/Tracker1/Resources/Classes/mfo/FeedMessage")
 
     gobject.set_application_name ("Rss/tracker")
     window = gtk.Window ()
diff --git a/python/rss_reader/signaler.py b/python/rss_reader/signaler.py
index 3ce53ea..6d19b80 100755
--- a/python/rss_reader/signaler.py
+++ b/python/rss_reader/signaler.py
@@ -25,13 +25,13 @@ import dbus.service
 from dbus.mainloop.glib import DBusGMainLoop
 import datetime, random
 
-TRACKER = 'org.freedesktop.Tracker'
-TRACKER_OBJ = '/org/freedesktop/Tracker/Resources'
+TRACKER = 'org.freedesktop.Tracker1'
+TRACKER_OBJ = '/org/freedesktop/Tracker1/Resources'
 
 # We are not inserting content, nor contributor!
 INSERT_SPARQL = """
 INSERT {
-<%s> a nmo:FeedMessage ;
+<%s> a mfo:FeedMessage ;
  nie:contentLastModified "%s" ;
  nmo:communicationChannel <http://maemo.org/news/planet-maemo/atom.xml>;
  nie:title "%s".
@@ -39,7 +39,7 @@ INSERT {
 """
 
 DELETE_SPARQL = """
-  DELETE { <%s> a nmo:FeedMessage. }
+  DELETE { <%s> a mfo:FeedMessage. }
 """
 
 class SignalerUI (gtk.Window):
@@ -50,7 +50,7 @@ class SignalerUI (gtk.Window):
         bus = dbus.SessionBus ()
         tracker = bus.get_object (TRACKER, TRACKER_OBJ)
         self.iface = dbus.Interface (tracker,
-                                     "org.freedesktop.Tracker.Resources")
+                                     "org.freedesktop.Tracker1.Resources")
 
         vbox = gtk.VBox ()
     
diff --git a/python/rss_reader/tracker_backend.py b/python/rss_reader/tracker_backend.py
index 23d0af8..4679594 100644
--- a/python/rss_reader/tracker_backend.py
+++ b/python/rss_reader/tracker_backend.py
@@ -20,15 +20,15 @@
 import dbus
 import os
 
-TRACKER = 'org.freedesktop.Tracker'
-TRACKER_OBJ = '/org/freedesktop/Tracker/Resources'
+TRACKER = 'org.freedesktop.Tracker1'
+TRACKER_OBJ = '/org/freedesktop/Tracker1/Resources'
 
 FALSE = "false"
 TRUE = "true"
 
 QUERY_FIRST_ENTRIES = """
     SELECT ?entry ?title ?date ?isRead WHERE {
-      ?entry a nmo:FeedMessage ;
+      ?entry a mfo:FeedMessage ;
          nie:title ?title ;
          nie:contentLastModified ?date .
     OPTIONAL {
@@ -43,16 +43,16 @@ SET_URI_AS_READED = """
 
 QUERY_ALL_SUBSCRIBED_FEEDS ="""
     SELECT ?feeduri ?title COUNT (?entries) AS e WHERE {
-       ?feeduri a nmo:FeedChannel ;
+       ?feeduri a mfo:FeedChannel ;
                 nie:title ?title.
-       ?entries a nmo:FeedMessage ;
+       ?entries a mfo:FeedMessage ;
                 nmo:communicationChannel ?feeduri.
     } GROUP BY ?feeduri
 """
 
 QUERY_FOR_URI = """
     SELECT ?title ?date ?isRead ?channel WHERE {
-      <%s> a nmo:FeedMessage ;
+      <%s> a mfo:FeedMessage ;
              nie:title ?title ;
              nie:contentLastModified ?date ;
              nmo:communicationChannel ?channel .
@@ -70,7 +70,7 @@ class TrackerRSS:
         bus = dbus.SessionBus ()
         self.tracker = bus.get_object (TRACKER, TRACKER_OBJ)
         self.iface = dbus.Interface (self.tracker,
-                                     "org.freedesktop.Tracker.Resources")
+                                     "org.freedesktop.Tracker1.Resources")
         self.invisible_feeds = []
         self.load_config ()
         
@@ -90,7 +90,7 @@ class TrackerRSS:
             f.close ()
         
     def get_post_sorted_by_date (self, amount):
-        results = self.iface.Query (QUERY_FIRST_ENTRIES % (amount))
+        results = self.iface.SparqlQuery (QUERY_FIRST_ENTRIES % (amount))
         return results
     
     def set_is_read (self, uri, value):
@@ -106,7 +106,7 @@ class TrackerRSS:
         """ Returns [(uri, feed channel name, entries, visible)]
         """
         componed = []
-        results = self.iface.Query (QUERY_ALL_SUBSCRIBED_FEEDS)
+        results = self.iface.SparqlQuery (QUERY_ALL_SUBSCRIBED_FEEDS)
         for result in results:
             print "Looking for", result[0]
             if (result[0] in self.invisible_feeds):
@@ -121,7 +121,7 @@ class TrackerRSS:
     def get_info_for_entry (self, uri):
         """  Returns (?title ?date ?isRead)
         """
-        details = self.iface.Query (QUERY_FOR_URI % (uri, uri))
+        details = self.iface.SparqlQuery (QUERY_FOR_URI % (uri, uri))
         if (len (details) < 1):
             print "No details !??!!"
             return None



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