GLib.List<GoogleMovie> results;
GoogleMovieService service;
+ public string path;
+ public string sender;
+
// D-Bus API
public void abort () {
// 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 () {
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);
}
void on_client_lost (DBus.Object sender, string name, string prev, string newp) {
if (newp == "") {
+ var remove_list = new SList<string> ();
// 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);
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);