From: Philipp Zabel Date: Thu, 8 Jul 2010 19:45:41 +0000 (+0200) Subject: Google backend: align with MoviePilot backend X-Git-Url: http://vcs.maemo.org/git/?a=commitdiff_plain;h=734478fbefb10017b750739063b0caf628d35785;hp=7546cb47acd780bdcbff4749c5bb5ff5ec50220f;p=cinaest Google backend: align with MoviePilot backend --- diff --git a/src/backends/google/google-backend.vala b/src/backends/google/google-backend.vala index 1b78685..7e4d89e 100644 --- a/src/backends/google/google-backend.vala +++ b/src/backends/google/google-backend.vala @@ -12,6 +12,9 @@ public class MovieSearch : Object { GLib.List results; GoogleMovieService service; + public string path; + public string sender; + // D-Bus API public void abort () { @@ -30,8 +33,10 @@ public class MovieSearch : Object { // Internal methods - internal MovieSearch (GoogleMovieService _service) { + internal MovieSearch (GoogleMovieService _service, string _sender, string _path) { service = _service; + sender = _sender; + path = _path; } private async void query_async () { @@ -102,25 +107,25 @@ public class MovieSearch : Object { public class GoogleMovieService : Object { private MainLoop loop; private uint source_id; + int id = 0; // D-Bus API public string new_search (DBus.BusName sender) { - print ("new search requested by %s\n", sender); - var search = new MovieSearch (this); - - search.id = searches.size; - string path = "/org/maemo/cinaest/googleshowtimes/search%d".printf (search.id); + var path = "/org/maemo/cinaest/moviepilot/search%d".printf (id); + var search = new MovieSearch (this, sender, path); + search.id = id++; conn.register_object (path, search); + print ("creating new search %s for %s\n", path, sender); searches.set (path, search); return path; } public void unregister (string path) { + print ("unregistering search %s\n", path); - print ("unregistering %s\n", path); searches.remove (path); print ("%d\n", searches.size); } @@ -153,15 +158,21 @@ public class GoogleMovieService : Object { void on_client_lost (DBus.Object sender, string name, string prev, string newp) { if (newp == "") { + var remove_list = new SList (); // We lost a client - print ("lost a client: prev:%s\n", prev); - searches.remove (prev); + print ("lost a client: %s\n", prev); + foreach (MovieSearch search in searches.values) { + if (search.sender == prev) { + print ("removing %s\n", search.path); + remove_list.append (search.path); + } + } + foreach (string path in remove_list) + searches.remove (path); } } void main () { - var loop = new MainLoop (null, false); - try { conn = DBus.Bus.get (DBus.BusType. SESSION); @@ -176,7 +187,7 @@ void main () { if (res == DBus.RequestNameReply.PRIMARY_OWNER) { var server = new GoogleMovieService (); - conn.register_object ("/org/maemo/cinaest/movies", server); + conn.register_object ("/org/maemo/cinaest/googleshowtimes", server); bus.NameOwnerChanged.connect (on_client_lost);