Hello, I have written a plugin that exports searches on dbus (it just
does a PROP_SEARCH_MATCH query on a string and returns a list of title,
artist, album, location) but I don't know how to make it appear on the
"org.gnome.Rhythmbox" bus name.

On the C version I have no problem, it just works (except that
deactivation does not remove it, but it can be fixed).

In order to distribute it easily I want to do a python version, when I
use dbus.service.BusName, I can set any name that is not already
registered, but not org.gnome.Rhythmbox which would be more appropriate.

By the way, the plugin is meant to be used by deskbar, empathy/pidgin
without the need of parsing the xml database, is this approach
acceptable or is it a feature that should be first approved and
developed in-tree ? maybe in order to have a compatible interface with
amarok or other similar software.

Patrick Nicolas

PS : Here is the plugin if you have time to investigate

import rhythmdb, rb
import gobject, gtk
import dbus, dbus.service
from dbus.mainloop.glib import DBusGMainLoop

DBusGMainLoop(set_as_default=True)
class DbusService(dbus.service.Object):
        def __init__(self, obj_path, db):
                bus = dbus.SessionBus()
                
bus_name=dbus.service.BusName(name="org.gnome.Rhythmbox",bus=bus)
                dbus.service.Object.__init__(self, bus, object_path=obj_path, 
bus_name=bus_name)
                self.db = db

        @dbus.service.method(dbus_interface='org.gnome.Rhythmbox.Query', 
in_signature='s', out_signature='a(ssss)', utf8_strings=True)
        def search (self, text):
                result_list=[]
                query = self.db.query_new()
                self.db.query_append(query,[rhythmdb.QUERY_PROP_LIKE, 
rhythmdb.PROP_SEARCH_MATCH, text.encode()])
                qm = self.db.query_model_new(query)
                self.db.do_full_query_parsed(qm,query)
                def read_entry_data (model, path, iter):
                        id = model.get(iter, 0)[0]
                        entry = self.db.entry_lookup_by_id(self.db.entry_get 
(id, rhythmdb.PROP_ENTRY_ID))
                        result_list.append((self.db.entry_get(entry, 
rhythmdb.PROP_ARTIST),
                                                                
self.db.entry_get(entry, rhythmdb.PROP_TITLE),
                                                                
self.db.entry_get(entry, rhythmdb.PROP_ALBUM),
                                                                
self.db.entry_get(entry, rhythmdb.PROP_LOCATION)))
                qm.foreach(read_entry_data)
                return result_list


class DbusQuery(rb.Plugin):

        def __init__(self):
                rb.Plugin.__init__(self)

        def activate(self, shell):
                db = shell.get_property("db")
                self.service = DbusService("/org/gnome/Rhythmbox/Query", db)

        def deactivate(self, shell):
                self.service = None
                print "dbus query plugin deactivated"




_______________________________________________
rhythmbox-devel mailing list
rhythmbox-devel@gnome.org
http://mail.gnome.org/mailman/listinfo/rhythmbox-devel

Reply via email to